一大 @ 2021-02-05 21:15:00
#include<bits/stdc++.h>
using namespace std;
double a,a1,b1,b;
int main(){
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++){
if(!i%k) a+=i,a1++;
else b+=i,b1++;
}
printf("%0.1f %0.1f",a/a1,b/b1);
}
awsl
by ud2_ @ 2021-02-05 21:19:08
@一大
!i%k
没看懂(
by 一大 @ 2021-02-05 21:22:41
@sjx233_ 就是i%k==0的意思啊
by Terrible @ 2021-02-05 21:24:49
@一大
优先级出问题了
!(i%k)
by yummy @ 2021-02-05 21:24:52
@一大 建议要么直接写==0,要么加括号,有可能先算了!i
by Nephrenn @ 2021-02-05 21:24:56
@一大 !优先级大于%
by Terrible @ 2021-02-05 21:26:09
by 一大 @ 2021-02-05 21:27:11
谢谢大神