UVA - 10056 What is the Probability ? 概率UVA - 10056 What is the Probability ?
2015-01-07 11:54
453 查看
题目大意:有N个人玩掷色子游戏,只要抛到某一特定的面就算赢了,而抛到这个面的概率是P,求第M个人赢的概率
解题思路:第M个人赢的概率是:
在第一轮赢了:K1
在第二轮赢了:K2
...
那么赢的概率就是K = K1 + K2 + 。。。 + KN
解题思路:第M个人赢的概率是:
在第一轮赢了:K1
在第二轮赢了:K2
#include<cstdio> #include<cstring> #include<cmath> using namespace std; int main() { int test, N, M ; double p; scanf("%d",&test); while(test--) { scanf("%d %lf %d",&N,&p,&M); int time = 1; M--; double ans = p * pow(1-p,M); double pre = 0.0; while(ans - pre > 1e-7) { pre = ans; ans += p * pow(1-p,N * time + M); time++; } printf("%.4lf\n",ans); } return 0; }
...
那么赢的概率就是K = K1 + K2 + 。。。 + KN
相关文章推荐
- uva10056 - What is the Probability ?(概率是多少)
- UVa 10056 What is the Probability ? (概率&有一个陷阱)
- uva 10056 - What is the Probability ?(概率)
- What is the Probability - UVa 10056 概率
- uva 10056 What is the Probability ? 概率是多少
- UVA - 10056 What is the Probability ?(概率)
- uva 10056 What is the Probability ?(简单概率)
- UVA 10056 - What is the Probability ?(概率)
- UVA10056 - What is the Probability ?(概率)
- uva 10056 - What is the Probability ?(概率)
- uva 10056 What is the Probability?
- UVA - 10056 What is the Probability ?
- UVa 10056 — What is the Probability?
- UVa 10056 - What is the Probability ?(等比数列求极限)
- UVA - 10056 What is the Probability
- UVA 10056 What is the Probability ?
- uva 10056 What is the Probability ?
- UVA 10056 What is the Probability ?
- UVA - 10056 What is the Probability ?
- uva 10056 - What is the Probability ?