xiao999yao @ 2024-08-22 21:55:33
C/C++(用python的拉出去斩了
我的:
#include<stdio.h>
int n,k,a,b,c,d;main(){scanf("%d%d",&n,&k);for(int i=1;i<=n;i++){i%k?d+=(b+=i,1):c+=(a+=i,1);}printf("%.1f %.1f",1.0*a/c,1.0*b/d);}
by xiao999yao @ 2024-08-22 21:57:04
更新:
#include<stdio.h>
int n,k,a,b,c,d,i;main(){scanf("%d%d",&n,&k);for(i=1;i<=n;i++)i%k?d+=(b+=i,1):c+=(a+=i,1);printf("%.1f %.1f",1.0*a/c,1.0*b/d);}
by ggc123 @ 2024-08-22 21:57:28
压行大佬
by FerventTemp0 @ 2024-08-23 04:58:21
直接推公式比你这个短到不知道哪里去了
by xiao999yao @ 2024-08-23 14:10:48
@FerventTemp0 有例子吗?