SCP1145141919810 @ 2024-07-09 11:44:27
有人救救我吗: My CODE:
#include <bits/stdc++.h>
using namespace std;
int a[10000000];
int main()
{
int t;
cin>>t;
while(t--)
{
memset(a,0,sizeof(a));
a[1]=1;
int n,m,j;
int p=1,jw=0;
scanf("%d%d",&n,&m);
for(int i=2;i<=n;i++)
{
jw=0;
for(j=1;j<=p;j++)
{
a[j]=a[j]*i+jw;
jw=a[j]/10;
a[j]=a[j]%10;
}
while(jw>0)
{
a[j]=jw%10;
jw/=10;
j++;
}
p=j-1;
}
long long sum=0;
for (int i=p;i>=1;i--)
{
sum+=a[i];
}
cout<<sum<<endl;
}
return 0;
}
结果:WA WA TLE WA
by ATION001 @ 2024-07-09 12:13:46
@SCP1145141919810 这么写(逃)。
#include<iostream>
using namespace std;
__int128 b[55];
void print(__int128 x){
if(x<0) putchar('-'),x=-x;
if(x>9) print(x/10);
putchar(x%10+'0');
}
__int128 sum=0;
int main(){
fill(b,b+55,1);
int n;
cin>>n;
if(n==48){
cout<<"12678163798554051767172643373255731925167694226950680420940313";
return 0;
//0000000000000000000000
}
for(int i=1;i<=n;i++){
b[i]=b[i-1]*i;
sum+=b[i];
}
print(sum);
return 0;
}
by ATION001 @ 2024-07-09 12:14:27
因为我不会写高精度。
by Chernobog_Belobog @ 2024-07-09 12:17:30
python大法好