2009-01-17 21:33:08來源不明

ACM 10220 I Love Big Numbers

請參考500!

/*************************************************************/

  1. #include<stdio.h>   
  2. #include<stdlib.h>   
  3. #include<string.h>   
  4. #include<math.h>   
  5. int math[1001][2601];   
  6. main()   
  7. {   
  8.  int a,b,n;   
  9.     math[0][0]=1;math[1][0]=1;   
  10.     for(a=2;a<1001;a++)   
  11.      {   
  12.       math[a][0]=0;   
  13.       for(b=0;b<2600;b++)   
  14.         {   
  15.          math[a][b]=math[a][b]+math[a-1][b]*a;   
  16.           if (math[a][b]>=10)   
  17.            {   
  18.             math[a][b+1]=math[a][b+1]+math[a][b]/10;   
  19.             math[a][b]=math[a][b]%10;   
  20.            }   
  21.         }   
  22.       }    
  23.  while(scanf("%d",&n)==1)   
  24.   {   
  25.    int temp=0;   
  26.    for(a=2599;a>=0;a--)   
  27.     {   
  28.      temp=temp+math[n][a];   
  29.     }   
  30.     printf("%d\n",temp);   
  31.   }   
  32.  return 0;   
  33. }  

上一篇:ACM 623 500!

下一篇:ACM 495 Fibonacci Freeze