标签:
1 #include<cstdio> 2 #include<iostream> 3 #include<cmath> 4 #include<cstring> 5 using namespace std; 6 int temp,n,a,k,ans[110000]; 7 int main(){ 8 while(scanf("%d",&n)!=EOF) 9 { 10 int count=1; 11 memset(ans,0,sizeof(ans)); 12 ans[0]=1; 13 14 for (int i=1;i<=n;++i) 15 { k=0; 16 for(int j=0;j<count;++j) 17 { 18 temp=ans[j]*i+k; 19 ans[j]=temp%10; 20 k=temp/10; 21 22 23 }while(k){ 24 ans[count++]=k%10; 25 k/=10; 26 } 27 } 28 for (int i=100000;i>=0;--i) 29 if (ans[i]) 30 { 31 count=i; 32 break; 33 } 34 for(int i=count;i>=1;--i) 35 { 36 printf("%d",ans[i]); 37 } 38 printf("%d\n",ans[0]); 39 } 40 41 return 0; 42 }
标签:
原文地址:http://www.cnblogs.com/fakerv587/p/5180943.html