偶数求和
#include <cstdio> int main() { int n, m; while(scanf("%d %d", &n, &m) != EOF) { int sum = 0, count = 0; for(int i = 2; i <= 2*n; i += 2) { sum += i; if((i/2) % m == 0) { count ++; if(count == 1) printf("%d", sum / m); else printf(" %d", sum / m); sum = 0; } } // printf("sum = %d\n", sum); if(sum != 0) { printf(" %d", sum / (n % m)); } printf("\n"); } return 0; }