- 【例27.1】 求整数的和与均值
a,s
- 2025-3-10 11:51:50 @
👎
57 comments
-
xiance128 LV 3 @ 2025-3-17 12:38:15
#include <bits/stdc++.h> using namespace std; int n, m, a, sum, cnt; int main() { cin >> n >> m; for (int i = 1; i < +n; i++) { cin >> a; if (sum + a > m) { cnt++; sum = a; } else sum += a; } cout << cnt + 1; return 0; }
-
2025-3-17 11:56:07@
#include <bits/stdc++.h> using namespace std; int n, m, a, sum, cnt; int main() { cin >> n >> m; for (int i = 1; i < +n; i++) { cin >> a; if (sum + a > m) { cnt++; sum = a; } else sum += a; } cout << cnt + 1; return 0; }
-
2025-3-17 11:53:47@
#include <bits/stdc++.h> using namespace std; int n; int main() { cin>>n; double e = 1, jc = 1; for (int i = 1; i <= n; i++) { jc *= i; e = e + 1 / jc; } printf("%.101f", e); return 0; }
-
2025-3-17 11:53:13@
#include <bits/stdc++.h> using namespace std; int n; int main() { cin>>n; double e = 1, jc = 1; for (int i = 1; i <= n; i++) { jc *= i; e = e + 1 / jc; } printf("%.101f", e); return 0; }
-
2025-3-17 11:42:23@
#include<bits/stdc++.h> using namespace std; int n, j, y, t, x, p, z;
int main(){ cin >> n; for(int i = 1;i <= 1;i++){ cin >> x >> p >> z; j += x; y += p; t += z; } cout<< j << " " << y << " " << t << " " << j + y + t; return 0; }
-
2025-3-17 11:42:13@
#include<bits/stdc++.h> using namespace std; int n, j, y, t, x, p, z;
int main(){ cin >> n; for(int i = 1;i <= 1;i++){ cin >> x >> p >> z; j += x; y += p; t += z; } cout<< j << " " << y << " " << t << " " << j + y + t; return 0; }
-
2025-3-10 13:10:19@
#include <bits/stdc++.h> using namespace std; int main() { for (int i=1; i<=20; i++) { if (i % 2 == 0) cout << i << "叮叮" << endl ; else if (i % 3 == 0) cout << i << "当当" << endl; else if (i%2 && i%3==0) cout << i << "叮叮当当" << endl; else cout<<i<<' '; } return 0; }
- ‹ Previous
- 1
- 2
Information
- ID
- 70
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- # Submissions
- 147
- Accepted
- 40
- Uploaded By