9 条题解
-
1余东霖 (yudonglin) LV 7 @ 2023-5-16 17:34:18
#include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> #include<bits/stdc++.h> using namespace std; const int N=1e6+10; int ans[N], len=1; void a(int x){ for(int i=0; i<len; i++){ ans[i] *= x; } for(int i=0; i<len; i++){ ans[i+1]+=ans[i]/10000; ans[i]%=10000; } while(ans[len]!=0){ ans[len+1]+=ans[len]/10000; ans[len]%=10000; len ++; } } int main(){ int n; cin >> n; ans[0]=1; for (int i=2; i<=n; i++){ a(i); } len --; cout << ans[len]; for(int i=len-1; i>=0; i--){ printf("%04d",ans[i]); } return 0; }//最后的输出采用格式化输出,超格,而前面不需要格式化输入
-
02024-6-16 12:38:56@
40分代码(别看) #include<iostream>
using namespace std;
int main()
{
int n,sum=1;
cin>>n;
if(n!=0){
for(int i=1;i<=n;i++){
sum=sum*i;}cout<<sum;}else{cout<<1;}
return 0;
}
-
02024-3-31 20:13:07@
#include<bits/stdc++.h> using namespace std; const int N=1e6+10; int ans[N], len=1; void a(int x){ for(int i=0; i<len; i++){ ans[i] *= x; } for(int i=0; i<len; i++){ ans[i+1]+=ans[i]/10000; ans[i]%=10000; } while(ans[len]!=0){ ans[len+1]+=ans[len]/10000; ans[len]%=10000; len ++; } } int main(){ int n; cin >> n; ans[0]=1; for (int i=2; i<=n; i++){ a(i); } len --; cout << ans[len]; for(int i=len-1; i>=0; i--){ printf("%04d",ans[i]); } return 0; }
-
02023-4-3 20:06:37@
#include<stack> #include<stdio.h> #include<iostream> #include<cstdio> #include<vector> #include<iomanip> #include<string.h> #include<math.h> #include<iostream> #include<bits/stdc++.h> using namespace std; const int N=1e6+10; int ans[N],len=1; void mul(int x) { for(int i=0;i<len;i++)ans[i]*=x; for(int i=0;i<len;i++) { ans[i+1]+=ans[i]/10000; ans[i]%=10000; } while(ans[len]!=0) { ans[len+1]=ans[len]/10000; ans[len]%=10000; len++; } } int main() { int n; cin>>n; ans[0]=1; for(int i=2;i<=n;i++)mul(i); len--; cout<<ans[len]; for(int i=len-1;i>=0;i--)printf("%04d",ans[i]); return 0; } //nima
-
02023-1-4 11:38:36@
#include<bits/stdc++.h> using namespace std; const int N=1e6+10; int ans[N],len=1; void mul(int x) { for(int i=0;i<len;i++)ans[i]*=x; for(int i=0;i<len;i++) { ans[i+1]+=ans[i]/10000; ans[i]%=10000; } while(ans[len]!=0) { ans[len+1]=ans[len]/10000; ans[len]%=10000; len++; } } int main() { int n; cin>>n; ans[0]=1; for(int i=2;i<=n;i++)mul(i); len--; cout<<ans[len]; for(int i=len-1;i>=0;i--)printf("%04d",ans[i]); return 0; }
-
-12022-11-12 16:20:57@
#include <queue> #include <math.h> #include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> using namespace std; #define LL long long const int N = 1e4 + 10; const int INF = 0x3f3f3f3f; long long len = 1 , a[N]; void mul(long long x) { for(int i = 0 ; i < len ; i++) a[i] *= x; for(int i = 0 ; i < len ; i++) { a[i+1] += a[i]/10000; a[i] %= 10000; } while(a[len] != 0) { a[len+1] = a[len]/10000; a[len] %= 10000; len++; } } int main() { int n; cin >> n; a[0] = 1; for(int i = 2 ; i <= n ; i++) mul(i); len--; cout << a[len]; for(int i = len-1; i >= 0 ; i--) printf("%04d",a[i]); return 0; }
-
-22022-11-12 16:15:33@
#include <queue> #include <stack> #include <vector> #include <math.h> #include <iomanip> #include <stdio.h> #include <iostream> #include <string.h> #include <algorithm> using namespace std; #define LL long long #define D double const int N=1e6+10; const int INF=0x3f3f3f3f; int len=1,a[N]; void mul(int x) { for(int i=0;i<len;i++) a[i]*=x; for(int i=0;i<len;i++) { a[i+1]+=a[i]/10000; a[i]%=10000; } while(a[len]!=0) { a[len+1]=a[len]/10000; a[len]%=10000; len++; } } int main() { int n; cin>>n; a[0]=1; for(int i=2;i<=n;i++) mul(i); len--; cout<<a[len]; for(int i=len-1;i>=0;i--) printf("%04d",a[i]); return 0; }
-
-22022-3-19 11:54:55@
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int a[N],len = 1; void mul(int p) { int k = 0; for(int i = 0;i < len;i++) { a[i] =a[i]*p+k; k = a[i]/10000; a[i] %= 10000; } while(k!=0) { a[len++] = k%10000; k = k /10000; } } int main() { int n; cin >> n; a[0]=1; for(int i=2;i <= n;i++) mul(i); cout << a[len-1]; len-=2; for(int i=len;i>=0;i--) printf("%04d",a[i]); return 0; }
-
-22022-1-8 19:45:35@
//确保AC #include <iostream> #include <cstdio> using namespace std; int a[100010] = {1}; int len = 0; int n; void f(int x) { int k = 0; for(int i = 0; i <= len; i++) { a[i] = a[i] * x + k; k = 0; if(a[i] >= 10000) { k = a[i] / 10000; a[i] %= 10000; } } while(k != 0) { a[++len] = k % 10000; k = k / 10000; } return; } int main() { cin >> n; for (int i = 1; i <= n; i++) f(i); cout << a[len]; for(int i = len - 1; i >= 0; i--) printf ("%04d", a[i]); return 0; }
- 1
信息
- ID
- 1202
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 7
- 标签
- 递交数
- 305
- 已通过
- 74
- 上传者