APian @ 2024-10-15 19:24:53
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
int n,k,a,b;
double A,B;
cin >> n >> k;
for (int i = 1; i <=n;i++){
if (i%k==0){
A += i;
a++;
}
else{
B += i;
}
}
b=n-a;
printf("%.1lf %.1lf",A/a,B/b);
return 0;
}
by LSC_IS_SB @ 2024-10-15 19:42:25
你有没有发现,变量全在主函数内,要先赋值为0