tocolorful @ 2022-11-18 11:58:34
以下是源码
#include <iostream>
using namespace std;
int a[10000];
int b[10000
int c[10000];
int ans1, ans2;
int jishu1, jishu2;
double lans1,lans2;
int main()
{
int n, k;
cin >> n >> k;
for (int i = 1;i <= n;i++)
c[i] = i;
for (int j = 1;j <= n;j++)
{
if (c[j] % k == 0)
{
a[j] = c[j];
jishu1++;
}
else
{
b[j] = c[j];
jishu2++;
}
}
for (int l = 1;l <= n;l++)
{
ans1 = a[l] + ans1;
}
for (int p = 1;p <= n;p++)
{
ans2 = ans2 + b[p];
}
lans1 = (double)ans1 / jishu1;
lans2 = (double)ans2 / jishu2;
printf("%.1lf", lans1);
printf("%.1lf", lans2);
return 0;
}