HDU 1001 Sum Problem(AC代码)

 

 

 

 

 1 #include <stdio.h>
 2 int main(){
 3         int k,sum;
 4         while(scanf("%d",&k)!=EOF){
 5             if(k%2==0){
 6                 sum=(1+k)*(k/2);
 7             }
 8             else{
 9                 sum=(1+k)*(k/2)+k/2+1;
10             }
11             printf("%d\n\n",sum);
12         }
13     return 0;
14 }

 

posted @ 2014-10-26 13:16  xcw0754  阅读(125)  评论(0编辑  收藏  举报