10056 - What is the Probability ?

来源:互联网 发布:网络运维投标书 编辑:程序博客网 时间:2024/05/01 16:25
/*简单概率题,一次AC*/#include <cstdio>int main(){//freopen("f://data.in", "r", stdin);int T;scanf("%d", &T);while(T--){int N, I;double p;scanf("%d %lf %d", &N, &p, &I);double q, t;int i;for(i = 0, t = 1; i < N; ++ i)t *= (1 - p);for(q = p, i = 1; i < I; ++ i)q *= (1 - p);double ans = q;while(q > 1e-6){q *= t;ans += q;}printf("%.4lf\n", ans);}return 0;}