UVa 11346 - Probability

来源:互联网 发布:java 堆栈使用 编辑:程序博客网 时间:2024/06/07 05:55

纯粹数学题,推公式吧。注意边界处理精度控制就可以了。

#include <cstdio>#include <cmath>#define EPS 1e-7int main(){int T; scanf("%d", &T);while (T--){double a, b, S; scanf("%lf %lf %lf", &a, &b, &S);if (S - a *b >= EPS) puts("0.000000%");else if (S <= EPS) puts("100.000000%");else printf("%f%%\n", (a *b - S - S * log(a * b / S)) / (a * b) * 100);}return 0;}


0 0
原创粉丝点击