40分求助!

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

ZYCH666 @ 2023-12-17 14:07:43

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;
int main(void)
{
    int n,k;
    cin>>n>>k;
    int ad=0,bd=0;
    double a=0,b=0;
    for (int i=1;i<=n;i++)
    {
        if (i%k==0)
        {
            a+=i;
            ad++;
        }
        else
        {
            b+=i;
            bd++;
        }
    }
    cout<<fixed<<setprecision(1)<<b/bd<<" "<<a/ad;
    return 0;
}

by __yiLIUyi__ @ 2024-01-05 17:57:07

输出是不是反了?


by superleo @ 2024-04-17 20:27:19

0分求助!


|