sadly_shark @ 2023-03-06 21:31:12
#include<bits/stdc++.h>
using namespace std;
float q,p,a,b;
int n,k;
int main(){
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++){
if(i%k==0)q++,p+=i;
else a++,b+=i;
}
printf("%.1f %.1f",p/q,b/a);
}
样例1,2正确 想问问为什么
by ZM____ML @ 2023-03-06 21:35:14
@JN_Flora 改成double,应该是精度问题
by sadly_shark @ 2023-03-06 21:36:52
@ZM____ML 谢谢大佬,AC了