liuzixuancluo @ 2024-10-17 22:12:51
#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;
}
by LuoShui_ @ 2024-10-18 21:50:30
大佬是在开玩笑吧
#include<stdio.h>
int main(){
int n, k;
double suma=0,sumb=0,a=0,b=0;
scanf("%d %d",&n,&k);
for (int i = 1; i <= n;i++)
{
if(i%k==0)
a++, suma += i;
else
b++, sumb += i;
}
printf("%.1lf %.1lf",suma/a,sumb/b);
return 0;
}