2009-01-17 21:33:08來源不明
ACM 10220 I Love Big Numbers
請參考500!
/*************************************************************/
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<math.h>
- int math[1001][2601];
- main()
- {
- int a,b,n;
- math[0][0]=1;math[1][0]=1;
- for(a=2;a<1001;a++)
- {
- math[a][0]=0;
- for(b=0;b<2600;b++)
- {
- math[a][b]=math[a][b]+math[a-1][b]*a;
- if (math[a][b]>=10)
- {
- math[a][b+1]=math[a][b+1]+math[a][b]/10;
- math[a][b]=math[a][b]%10;
- }
- }
- }
- while(scanf("%d",&n)==1)
- {
- int temp=0;
- for(a=2599;a>=0;a--)
- {
- temp=temp+math[n][a];
- }
- printf("%d\n",temp);
- }
- return 0;
- }
上一篇:ACM 623 500!