15 条题解
-
-1
兄弟们,为什么ans和sum不能开long long,int就行?大佬求解 longlong代码:(错的,不要复制)
#include <iostream> #include <bits/stdc++.h> using namespace std; const int N=1e7+10; const int INF=0x3f3f3f3f; int main() { int n; long long sum=1,ans; cin>>n; for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { sum*=j; } ans+=sum; sum=1; } cout<<ans; }
int代码:
#include <iostream> #include <bits/stdc++.h> using namespace std; const int N=1e7+10; const int INF=0x3f3f3f3f; int main() { int n; int sum=1,ans; cin>>n; for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { sum*=j; } ans+=sum; sum=1; } cout<<ans; }
-
-5
- 1
信息
- ID
- 932
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 4
- 标签
- 递交数
- 754
- 已通过
- 354
- 上传者