0分求助

P5719 【深基4.例3】分类平均

L_sky @ 2021-02-24 17:09:15

#include<bits/stdc++.h>
using namespace std;

int main() {
    int n, k;
    int Asum = 0, Bsum = 0;
    scanf ("%d%d", &n, &k);
    for (int i = k; i <= n; i += k) {
        Asum += i;
    }
    Bsum = (1 + n) * n / 2 - Asum;
    printf ("%.1f", double(Asum) / (n / k));
    printf ("%.1f", double(Bsum) / (n - n / k));
    return 0;
}

by yekgg @ 2021-02-24 17:28:23

输出没加空格


by yekgg @ 2021-02-24 17:29:48

下次请先测试代码在提问,谢谢


|