标签:
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 60244 Accepted Submission(s): 17166
1 #include <iostream> 2 #include<stdio.h> 3 #include<string.h> 4 #include<math.h> 5 #include<stdlib.h> 6 using namespace std; 7 int a[8000]; 8 int main() 9 { 10 int n; 11 int i,j; 12 while(~scanf("%d",&n)) 13 { 14 if(n==0) 15 { 16 printf("1\n"); 17 continue; 18 } 19 memset(a,0,sizeof(a)); 20 a[0]=1; 21 for(i=2;i<=n;i++) 22 { 23 for(j=0;j<8000;j++) 24 a[j]*=i; 25 for(j=0;j<8000;j++) 26 { 27 a[j+1]+=a[j]/100000; 28 a[j]%=100000; 29 } 30 } 31 for(i=8000;i>=0;i--) 32 { 33 if(a[i]!=0) 34 break; 35 } 36 printf("%d",a[i--]); 37 for(;i>=0;i--) 38 printf("%05d",a[i]); 39 printf("\n"); 40 } 41 return 0; 42 } 43 ----------------------------------------------- 44 #include <iostream> 45 #include<stdio.h> 46 #include<string.h> 47 #include<math.h> 48 #include<stdlib.h> 49 using namespace std; 50 int a[100000]; 51 int main() 52 { 53 //freopen("in.txt","r",stdin); 54 int n; 55 int i,j,temp; 56 while(~scanf("%d",&n)) 57 { 58 memset(a,0,sizeof(a)); 59 a[0]=1; 60 int count=1; 61 for(i=1;i<=n;i++) 62 { 63 int k=0; 64 for(j=0;j<count;j++) 65 { 66 temp = a[j]*i+k; 67 a[j]=temp%10; 68 k=temp/10; 69 } 70 while(k) 71 { 72 a[count++]=k%10; 73 k/=10; 74 } 75 } 76 for(i=100000;i>=0;i--) 77 { 78 if(a[i]!=0) 79 break; 80 } 81 for(;i>=0;i--) 82 printf("%d",a[i]); 83 printf("\n"); 84 } 85 return 0; 86 }
标签:
原文地址:http://www.cnblogs.com/xuesen1995/p/4333445.html