Golden_azy @ 2021-10-04 20:04:23
#include <iostream>
using namespace std;
int x[105000];
int y[100090];
int main() {int i;
int a,b=1;int c=0,d=0;
scanf("%d%d",&a,&b);
for(i=1;i<=a;i=i+1){if(i%b==0){c=c+1;x[c]=i;
}else d=d+1;y[d]=i;
}
int s=0,t=0;
for(i=1;i<=c;i=i+1){s=s+x[i];
}
for(i=1;i<=d;i=i+1){t=t+y[i];
}
printf("%.1lf %.1lf",s/(double)c,t/(double)d);
return 0;
}
为什么精度不对?样例的第二个数差0.1
by _l_l_ @ 2021-10-04 20:07:26
}else d=d+1;y[d]=i;
改为
}else {d=d+1;y[d]=i;}
by Golden_azy @ 2021-10-04 20:31:34
@disangan223 谢谢,这里真的大意了没看见