_cheems_ckr_ @ 2024-05-03 23:09:23
#include<bits/stdc++.h>
using namespace std;
int n,k,ans=0,ans1=0,num=0,num1=0;
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++){
if(i%k==0){
ans++;
ans1+=i;
}else{
num++;
num1+=i;
}
}
double a,b;
a=double(ans1/ans);
b=double(num1/num);
printf("%.1lf %.1lf",a,b);
return 0;
}
by _cheems_ckr_ @ 2024-05-03 23:12:42
悬关
求大佬
by kmst_ayk @ 2024-05-03 23:42:11
第16,17行改成下面这样:
a=double(ans1)/ans;
b=double(num1)/num;
by cmask4869 @ 2024-05-03 23:43:45
@_cheemsckr 中间不用这么麻烦,这样就 ok 了:
for (int i=k ; i<=n ; i+=k) sum+=i ;
by _cheems_ckr_ @ 2024-05-04 09:51:46
哦,感谢大佬 @kmst_ayk @cmask4869
by abcd987654321 @ 2024-05-25 10:34:12
@_cheemsckr SB
by geyijin @ 2024-05-26 19:41:39
****
by geyijin @ 2024-05-26 19:42:09
@abcd987654321 有没有素质