偶数求和

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;
   7     while(scanf("%d%d", &n, &m)!=EOF) {
   8         int i;
   9         for(i = 2; i <= 2*n; i+= 2*m) {
  10             if(2*n-i <= 2*(m-1)) {
  11                 printf("%d\n", n+i/2);
  12             }
  13             else
  14                 printf("%d ", i+m-1);
  15         }
  16     }
  17 }
ch3n2k.com | Copyright (c) 2004-2020 czk.