guoen23 @ 2024-07-11 17:14:19
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,e = 0;
long long int d,f = 0;
double g,h = 1.0;
cin>>a>>b;
for(int i = 1;i<=a;i++){
if(i % b == 0){
c++;
e+=i;
}
else{
d++;
f+=i;
}
}
g = e * 1.0 / c;
h = f * 1.0 / d;
cout<<fixed<<setprecision(1)<<g<<" ";
cout<<fixed<<setprecision(1)<<h;
return 0;
}
求调[(ToT)/~~~]
by Ame_wiki @ 2024-07-11 17:16:09
qp
by lpk1118 @ 2024-07-11 17:20:13
可能是c,d,g没有赋初始值
by ayszYW @ 2024-07-11 17:21:08
a,b,c,d,g没有赋初始值
可以改成全局变量自动赋0
by guoen23 @ 2024-07-12 20:22:18
@ayszYW haode @lpk1118 好的,谢谢!
by guoen23 @ 2024-07-12 20:25:49
@guoen23 已经AC