Fryderyk_Chopin @ 2023-04-25 12:15:40
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n,k;
int i,a=0,b=0,sum1=0,sum2=0;
for(i=1;i<=n;i++)
{
if(i%k==0)
{
a=a+i;
sum1++;
}
else
{
b=b+i;
sum2++;
}
}
double c,d;
c=a/sum1;
d=b/sum2;
cout<<fixed<<setprecision(1)<<c;
cout<<fixed<<setprecision(1)<<d;
return 0;
}
一直RE,大佬救救我吧
by LBYYSM_123 @ 2023-04-25 12:59:50
首先将cin>>n,k;
改为cin>>n>>k;
,并将c=a/sum1;d=b/sum2;
改c=1.0*a/sum1;d=1.0*b/sum2;
by LBYYSM_123 @ 2023-04-25 13:01:28
输出结果中间也要打空格
by ZYK_luogu @ 2023-05-06 00:28:33
用printf不香吗
by Fryderyk_Chopin @ 2023-11-23 13:11:53
@LBYYSM_123 谢谢,那时候太菜了(嘿嘿)