偶数求和

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

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

hdu2015 (last edited 2008-06-01 16:59:38 by czk)

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