guyilin129 @ 2023-12-02 19:37:19
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,x=0,y=0;
double a,b;
cin>>n>>k;
for(int i=1;i<=n;i++){
if(i%k==0) {
x+=i;
a++;
}
}
for(int i=1;i<=n;i++){
if(i%k!=0){
y+=i;
b++;
}
}
if(a!=0){
cout<<fixed<<setprecision(1)<<x/a;
}else{
cout<<0.0;
}if(b!=0){
cout<<fixed<<setprecision(1)<<" "<<y/b;
}else{
cout<<0.0;
}
return 0;
}
by Weizhuo_Zhao @ 2023-12-02 19:49:39
@guyilin129 setprecision(x)是啥函数?
by GPUawa @ 2023-12-03 18:01:37
@Weizhuo_Zhao 控制输出几位小数
by GPUawa @ 2023-12-03 18:13:30
@guyilin129 你a和b没初始化为0
你谷评测姬用的linux,所以你在本地运行时会发现样例和点都是过的而你谷不行
by Weizhuo_Zhao @ 2023-12-04 18:08:45
@GPUawa 知识+1
by guyilin129 @ 2023-12-05 15:01:05
@GPUawa 谢谢AC了