symons

___________每一天都是幸福的!!

  博客园  ::  :: 新随笔  ::  :: 订阅 订阅  :: 管理

为了凑今天的数,大水题。不解释了,说来惭愧。

 1 #include <stdio.h>
 2 int main(){
 3     int n;
 4     int i,cnt,j;
 5     int tot;
 6     while(~scanf("%d",&n)){
 7         if(n==0) break;
 8         tot=0;
 9         cnt=1;
10         j=0;
11         for(i=1;i<=n;++i){
12             tot+=cnt;
13             j++;
14             if(j==cnt){
15                 j=0;
16                 cnt++;
17             }
18         }
19         printf("%d %d\n",n,tot);
20     }
21     return 0;
22 }

 

posted on 2014-01-14 21:51  symons  阅读(167)  评论(0)    收藏  举报