poj2000

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

 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,tot);
20     }
21     return 0;
22 }
原文地址:https://www.cnblogs.com/symons1992/p/3519831.html