gaoshouchangmu @ 2024-11-02 15:59:06
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
int n,k;
n=s.nextInt();
k=s.nextInt();
float sum1=0,sum2=0,c=0,j=0;
for(int i=1;i<=n;i++){
if(i%k==0){
sum1+=i;
c++;
}else{
sum2+=i;
j++;
}
}
float ans1=sum1/c;
float ans2=sum2/j;
System.out.printf("%.1f %.1f",ans1,ans2);
}
}
by Hagasei @ 2024-11-02 16:06:31
@gaoshouchangmu float 精度太低了,,算法竞赛里面浮点数尽量都用 double。
by gaoshouchangmu @ 2024-11-02 16:22:35
@Hagasei 通过了,感谢