您的位置:首页 > 其它

uva 10056 What is the Probability ?(简单概率)

2014-12-28 17:08 399 查看
题意:。。

思路:直接算出公式。。注意 p=0 的情况

#include<bits/stdc++.h>
using namespace std;

#define SPEED_UP iostream::sync_with_stdio(false);
#define FIXED_FLOAT cout.setf(ios::fixed, ios::floatfield);
#define rep(i, s, t) for(int (i)=(s);(i)<=(t);++(i))
#define urep(i, s, t) for(int (i)=(s);(i)>=(t);--(i))

typedef long long LL;

const int Maxn = 50;

int t, n, k;
double p;

int main() {
#ifndef ONLINE_JUDGE
freopen("input.in", "r", stdin);
#endif
SPEED_UP
FIXED_FLOAT
cin >> t;
while (t--) {
cin >> n >> p >> k;
if (p == 0) {
cout << "0.0000" << endl;
continue;
}
double q = pow(1-p, n);
double ans = pow(1-p, k-1) * p / (1-q) ;
cout << setprecision(4) << ans << endl;
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: