zkdphy @ 2024-01-31 10:28:23
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,c=0,tot=0;
double A,B,sum,ans;
cin>>n>>k;
for(int i=1;i<=n;i++){
if(i%k==0){
sum+=i;
tot++;
}
else{
ans+=i;
c++;
}
A=sum/tot;
B=ans/c;
}
printf("%.1f %.1f",A,B);
return 0;
}
by jinglinbankemeng @ 2024-01-31 10:31:04
你看私信!
by jinglinbankemeng @ 2024-01-31 10:34:40
你把double A,B,sum,ans;改成double A,B,sum=0,ans=0;就可以AC!