#include <stdio.h> #include <stdlib.h> int main(void) { int *a, n, m, quot, remain, aver, sum; int i, j, k; while(scanf("%d%d", &n, &m) == 2) { a = (int *)malloc(sizeof(int) * n); for(i = 0; i < n; i++) { a[i] = (i + 1) * 2; } quot = n / m; remain = n % m; for(i = 0; i < quot; i++) { sum = 0; for(j = 0; j < m; j++) { sum += a[i * m +j]; } printf("%d ", sum / m); } sum = 0; if(remain != 0) { for(i = n - remain; i < n; i++) { sum += a[i]; } printf("%d\n", sum / remain); } else printf("\n"); } return 0; }
0.0分
0 人评分