lhyjiy @ 2024-10-04 09:20:52
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
using namespace std;
vector<int> a;
int b[1000050];
int main(){
int n;cin>>n;
a.push_back(1);
int cnt;
for(int i=1;i<=n;i++){
cnt=a.size()+3;
for(int j=0;j<cnt;j++){
a[j]*=i;
if(a[j]>=100){
a[j+2]+=a[j]/100;
a[j+1]+=a[j]/10;
a[j]%=10;
}
else if(a[j]>=10){
a[j+1]+=a[j]/10;
a[j]%=10;
}
}
cnt++;
for(int j=0;j<cnt;j++){
b[j]+=a[j];
b[j+1]+=b[j]/10;
b[j]%=10;
}
}
cnt++;
while(b[cnt]==0) cnt--;
for(int i=0;i<cnt;i++)
cout<<b[i];
return 0;
}
by abssortpow1145145 @ 2024-10-10 21:37:24
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,k[100005]={0},l;
cin >> n;
for(int p=1;p<=n;p++)
{
int x=p,xk[10005]={1},len=1;
for(int i=1;i<=x;i++)
{
int j,t=0;
for(j=0;j<len || t!=0;j++)
{
int s=xk[j]*i+t;
xk[j]=s%10;
t=s/10;
}
len=j;
}
int h,tk=0;
for(h=0;h<len || tk!=0;h++)
{
int v=xk[h]+k[h]+tk;
k[h]=v%10;
tk=v/10;
}
l=len;
}
for(int i=l-1;i>=0;i--)
{
cout << k[i];
}
return 0;
}
AC代码求关
by lhyjiy @ 2024-10-11 21:52:30
@abssortpow1145145 谢谢,已关