40分求助
查看原帖
40分求助
452450
CadeShuWindsor楼主2021/3/3 21:40
#include<bits/stdc++.h>
using namespace std;
int main()
{
	float a=0,b=0;
	int n,k,c=0,m=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		if(i%k == 0)
	    {
		a+=i;
		c+=1;
	    }
	    else
	    {
	    b+=i; 
	    m+=1;
	    }
	}
	float ap=a/c,bp=b/m;
	cout<<fixed<<setprecision(1)<<ap;
	cout<<" ";
	cout<<fixed<<setprecision(1)<<bp;

}
2021/3/3 21:40
加载中...