Wanzm_Alymine @ 2023-02-03 22:11:16
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, k, a = 0, b = 0, c = 0;
double sum1 = 0, sum2 = 0;
cin >> n >> k;
for (int i = 1;i <= n;i ++)
{
a ++;
if (n%k == 0)
{
sum1 = sum1 + a;
b ++;
}
else
{
sum2 = sum2 + a;
c ++;
}
}
cout << fixed << setprecision(1) << sum1 / b * 1.0;
cout << " " << fixed << setprecision(1) << sum2 / c * 1.0;
return 0;
}
我不李姐
by Mr_Min @ 2023-02-04 08:15:08
@Wanzm
if (n%k == 0)
{
sum1 = sum1 + a;
b ++;
}
改为
if (i%k == 0)
{
sum1 = sum1 + a;
b ++;
}
by Wanzm_Alymine @ 2023-02-04 08:17:53
@Mr_Min thx