Ascano @ 2023-11-29 23:59:24
#include <stdio.h>
int main() {
int n, k;
int q, p = 0;
scanf("%d %d", &n, &k);
int b, c = 0;
for (int i = 1; i <= n; i++) {
if (i % k == 0) {
b = i + b;
q++;
} else {
c = i + c;
p++;
}
}
double x = b / (q * 1.0);
double y = c / (p * 1.0);
printf("%.1f %.1f", x, y);
return 0;
}
by penguin_is_cool @ 2023-11-30 07:48:07
@Ascano 建议全用double可能更方便一些
by Ascano @ 2023-11-30 23:32:09
@penguin_is_cool 用int应该......影响不大吧