uva623
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=564
解法和杭电acm1042一样,输出格式不一样
View Code
1 #include<stdio.h> 2 int main() 3 { 4 long n,m,i,j,b; 5 long a[100000]; 6 while(scanf("%ld",&n)!=EOF) 7 { 8 9 a[0]=1; 10 m=1; 11 for(i=1;i<=n;i++) 12 { 13 b=0; 14 for(j=0;j<m;j++) 15 { 16 a[j]=a[j]*i+b; 17 b=a[j]/10000; 18 a[j]=a[j]%10000; 19 } 20 if(b>0) 21 { 22 a[m]=b; 23 m++; 24 } 25 } 26 27 printf("%d!\n%ld",n,a[m-1]); 28 for(i=m-2;i>=0;i--) 29 { 30 printf("%4.4ld",a[i]); 31 } 32 printf("\n"); 33 } 34 return 0; 35 }