LUHAOLUHAO @ 2023-03-07 12:12:30
很晕
#include<bits/stdc++.h>
using namespace std;
double a=0,b=0,aa=0,bb=0;
int n,k;
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++){
if(i%k==0){
a+=i;
aa++;
}else{
b+=i;
bb++;
}
}
printf("%1lf %1lf",a/aa,b/bb);
return 0;
}
by InversionShadow @ 2023-03-07 12:33:32
用 cout
不香吗
by LUHAOLUHAO @ 2023-03-07 12:37:07
题目说要保留一位小数,谢谢
by LBYYSM_123 @ 2023-03-07 12:40:52
printf("%1lf %1lf",a/aa,b/bb);
应改为
printf("%.1lf %.1lf",a/aa,b/bb);
by LUHAOLUHAO @ 2023-03-07 12:44:11
OK,谢谢!