PION_ @ 2024-12-07 20:06:14
#include<bits/stdc++.h>
#pragma G++ optimize(1)
#pragma G++ optimize(2)
#pragma G++ optimize(3)
using namespace std;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int n,k;
cin>>n>>k;
double suma,sumb,cnta,cntb;
double ansa,ansb;
for(int i=1;i<=n;i++)
{
if(i%k==0)
{
suma+=i;
cnta++;
}
else
{
sumb+=i;
cntb++;
}
}
ansa=suma*1.0/cnta;
ansb=sumb*1.0/cntb;
printf("%.1lf %.1lf",ansa,ansb);
return 0;
}
by PION_ @ 2024-12-07 20:07:47
个人觉得和
#pragma G++ optimize(1)
#pragma G++ optimize(2)
#pragma G++ optimize(3)
std::ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
没关系
by ma_rui @ 2024-12-27 22:26:12
说实话我没看懂你头文件后写的是什么东西
不过你看一下我的AC代码
#include<bits/stdc++.h>
using namespace std;
int n,k,ansa,suma,ansb,sumb;
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++){
if(i%k==0){
ansa+=i;
suma++;
}else{
ansb+=i;
sumb++;
}
}
cout<<fixed<<setprecision(1)<<1.0*ansa/suma<<" "<<fixed<<setprecision(1)<<1.0*ansb/sumb;
return 0;
}
求互关