AlexKun @ 2023-02-19 14:07:56
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n , k;
double a = 0 , b = 0 , suma = 0 , sumb = 0;
cin >> n >> k;
for(int i = 1; i <= n; i++)
{
if(i % k == 0)
{
a++;
suma += i;
}
else
{
b++;
sumb += i;
}
}
printf("%.1f\n" , suma / a * 1.0);
cout << " ";
printf("%.1f\n" , sumb / b * 1.0);
return 0;
}
注:a,b存的是a ,b类数的个数,而suma,sumb存的是a,b类数之和
by Loser_Syx @ 2023-02-19 14:11:30
@AlexKun 空格间隔,你多换行干嘛
by AlexKun @ 2023-02-19 14:16:30
感谢已AC 我怎么瞎了