http://acm.nyist.net/JudgeOnline/problem.php?pid=28
50
30414093201713378043612608166064768844377641568960512000000000000
1 #include<stdio.h> 2 #include<math.h> 3 int main(){ 4 int n; 5 while(scanf("%d",&n)!=EOF){ 6 long a[10000]; 7 int i,j,l,c,m=0,w; 8 a[0]=1; 9 for(i=1;i<=n;i++){ 10 c=0; 11 for(j=0;j<=m;j++){ 12 a[j]=a[j]*i+c; 13 c=a[j]/10000; 14 a[j]=a[j]%10000; 15 } 16 if(c>0) {m++;a[m]=c;} 17 } 18 19 w=m*4+log10(a[m])+1; 20 printf("%ld",a[m]); 21 for(i=m-1;i>=0;i--) printf("%4.4ld",a[i]); 22 printf("\n"); 23 } 24 return 0; 25 }
大数阶乘位数的计算方法是(int)log10(x)+1
这个是计算x的位数的
log10(n!)=log10(1)+log10(2)+log10(3)+...+log10(n)
原文:http://www.cnblogs.com/HRuinger/p/3739285.html