Sum Problem

http://acm.hdu.edu.cn/showproblem.php?pid=1001

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

hdu1001 (2008-06-01 13:51:32由czk编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.