zsy_NKU @ 2022-11-03 10:56:10
#include<iostream>
using namespace std;
int main()
{
int n,k,a=0,b=0,c=0,d;
cin>>n>>k;
for(int i=n;i;i--)
{if(i%k==0){a+=i;c++;}
else b+=i;}
d=n-c;
cout<<a*1.0/c<<" "<<b*1.0/d;
}
by happy_zero @ 2022-11-03 11:28:00
@zsy_NKU
printf("%.1f %.1f",a*1.0/c,b*1.0/d);
输出保留一位小数
by zsy_NKU @ 2022-11-03 18:58:59
@zhuoyuxuan 我的源代码有保留一位的呀
by zsy_NKU @ 2022-11-03 20:16:39
@zsy_NKU 抱歉确实