0分求助
查看原帖
0分求助
1387055
liuzixuancluo楼主2024/10/17 22:12
#include <cstdio>
#include <iostream>
using namespace std;

int main(int argc, char** argv) {
	int n,k;
	cin>>n>>k;
	int max,mas,max1,mas1;
	for(int i=1;i<=n;i++)
	{
		if(i%k==0)
		{
			max=max+i;
			max1++;
		}
		else
		{
			mas=mas+i;
			mas1++;
		}
	}
	double a,b;
	a=max*1.0/(max1*1.0);
	b=mas*1.0/(mas1*1.0);
	int e;
	e=a*10;
	double f;
	f=e*1.0;
	a=f/10;
	int c;
	c=b*10;
	double d;
	d=c*1.0;
	b=d/10;
	printf("%.1f",a);
	cout<<" ";
	printf("%.1f",b);
	return 0;
}

2024/10/17 22:12
加载中...