24h購物| | PChome| 登入
2009-01-11 15:21:45| 人氣1,049| 回應0 | 上一篇 | 下一篇

ACM 10013 Super long sums

推薦 0 收藏 0 轉貼0 訂閱站台

這種可能會很大的測資,幾乎都要設在全區變數!而且不曉得會進幾位要用WHILE

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

  1. #include<stdio.h>   
  2. #include<stdlib.h>   
  3. #include<string.h>   
  4. #include<math.h>   
  5. int ans1[1000000];   
  6. main()   
  7. {   
  8.  int a,b,c,d,n,n1,a1,a2,time;   
  9.  while(scanf("%d",&n)==1)   
  10.   {   
  11.    for(a=0;a<n;a++)   
  12.     {   
  13.      scanf("%d",&n1);   
  14.      for(b=n1-1;b>=0;b--)   
  15.       {   
  16.       scanf("%d %d",&a1,&a2);   
  17.       ans1[b]=a1+a2;   
  18.       }   
  19.       ans1[n1]=0;   
  20.      for(c=0;c<n1;c++)   
  21.       {   
  22.        time=0;   
  23.        while(ans1[c]>=10)   
  24.         {   
  25.          time++;   
  26.          ans1[c]=ans1[c]-10;   
  27.         }   
  28.        ans1[c+1]=ans1[c+1]+time;    
  29.       }   
  30.      for(c=n1;c>=0;c--)   
  31.       {   
  32.        if(ans1[c]!=0)   
  33.        {   
  34.         for(d=c;d>=0;d--)   
  35.          printf("%d",ans1[d]);     
  36.          printf("\n");   
  37.          break;   
  38.        }     
  39.       }    
  40.     }   
  41.   }   
  42.  return 0;   
  43. } 

台長: 來源不明
人氣(1,049) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 數位資訊(科技、網路、通訊、家電) | 個人分類: ACM |
此分類下一篇:ACM 392 Polynomial Showdown
此分類上一篇:ACM 10038 Jolly Jumpers

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文