刘汝佳厚书P7
代码如下:
int main() { #ifndef ONLINE_JUDGE freopen("in","r",stdin); freopen("out","w",stdout); #endif int n, m; while(~scanf("%d%d", &n, &m)) { double ans = 0.0; for(int i = 1; i < n; ++i) { double t = (double)i/n*(n+m); ans += fabs(t-floor(t+0.5))/(n+m); } printf("%.4lf\n", ans*10000); } return 0; }