Zpy123 @ 2025-01-10 17:59:25
using namespace std; int main(){ int n,m,s; s=0;
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,s;
s=0;
cin>>n;
for(int i=1;i<=n;i++){
m=1;
for(int j=1;j<=i;j++){
m=j*m;
}
s=s+m;
}
cout<<s;
}
cin>>n;
for(int i=1;i<=n;i++){
m=1;
for(int j=1;j<=i;j++){
m=j*m;
}
s=s+m;
}
cout<<s;
}
by Hua_Tian @ 2025-01-10 18:44:23
哥,这是高精度,请看以下代码:
#include<bits/stdc++.h>
using namespace std;
int a[100000],n,i,y,xy[100000],s[100000];
void add(){
int i;
memset(xy,0,sizeof(xy));
xy[0]=max(s[0],a[0]);
for (i=1;i<=xy[0];i++){
xy[i]+=s[i]+a[i];
xy[i+1]=xy[i]/10;
xy[i]%=10;
}
while (xy[xy[0]+1]>0){
xy[xy[0]+2]=xy[xy[0]+1]/10;
xy[xy[0]+1]%=10;
xy[0]++;
}
s[0]=xy[0];
for (i=1;i<=xy[0];i++) s[i]=xy[i];
}
int main()
{
cin>>n;
a[0]=1;
a[1]=1;
s[0]=1;
s[1]=0;
for (y=1;y<=n;y++){
memset(xy,0,sizeof(xy));
xy[0]=a[0];
for (i=1;i<=a[0];i++){
xy[i]+=a[i]*y;
xy[i+1]=xy[i]/10;
xy[i]%=10;
}
while (xy[xy[0]+1]>0){
xy[xy[0]+2]=xy[xy[0]+1]/10;
xy[xy[0]+1]%=10;
xy[0]++;
}
for (i=1;i<=xy[0];i++) a[i]=xy[i];
a[0]=xy[0];
add();
}
for (i=s[0];i>=1;i--)cout<<s[i];
return 0;
}
by chenxitao @ 2025-01-10 19:19:06
#include<bits/stdc++.h>
using namespace std;
int n,a[90],b[90],c[90],f[90],d,x,y=1,z=1,l,m=1;
string s;
int main(){
cin>>n;
b[0]=1;
for(int i=1;i<=n;i++){
x=0;
int p=i;
while(p>0){
a[x++]=p%10;
p/=10;
}
for(int j=0;j<x;j++)for(int k=0;k<=y;k++)c[j+k]+=a[j]*b[k];
for(int j=0;j<z;j++)if(c[j]>9)c[j+1]+=c[j]/10,c[j]%=10;
if(c[z])z++;
l=y,y=z,m=max(m,z);
for(int k=z-1;k>=0;k--) b[k]=c[k];
z=x+l;
memset(c,0,sizeof(c));
for(int j=0;j<m;j++){
f[j]+=b[j];
if(f[j]>9)f[j+1]+=f[j]/10,f[j]%=10;
}
}
while(!f[m]&&m>0)m--;
for(int i=m;i>=0;i--)cout<<f[i];
return 0;
}
by Hkueen @ 2025-01-10 19:23:51
@Zpy123悬棺是本好书啊