#include<iostream>
#include<cstring>
#include<stdio.h>
using namespace std;
const int maxn=7400;
int f[maxn];
int main()
{ int i,j,n;
while( cin>>n)
{ int q=0;
memset(f,0,sizeof(f));
f[0]=1;
for(i=2; i<=n; i++)
{ int c=0,s=0;
for(j=0; j<maxn; j++)
{ s=f[j]*i+c;
f[j]=s%100000;
c=s/100000;
}
}
for(j=maxn-1; j>=0; j--) if(f[j]) break;
//cout<<f[j];
char num[10];
sprintf(num,"%d",f[j]);
for(i=j-1; i>=0; i--)
// printf("%05d",f[i]);
q++;
// cout<<endl;
cout<<"结果有"<<strlen(num)+q*5<<"位"<<endl;
}
return 0;
}
阶乘N!求结果的位数 n<10000
最新推荐文章于 2020-12-10 03:51:27 发布