uva 10056 - What is the Probability ?(概率)
来源:互联网 发布:成交量指标源码 编辑:程序博客网 时间:2024/05/12 08:10
题目连接:uva 10056 - What is the Probability ?
题目大意:给出n和p以及m,表示有n个人在丢色子, 谁先丢到某个值就表示胜利,每个人丢到的胜利数值的概率都为p,问第m个人获胜概率。
解题思路:因为n个人可以轮流丢色子,所以要自己定一个下限,而且以为人数比较多,每次并不需要将m以外的人都考虑进去,可以默认为没有丢到胜利的数值。
#include <stdio.h>const double tmp = 1e-7;int main () {int cas, n, aid;double p, q;scanf("%d", &cas);while (cas--) {scanf("%d%lf%d", &n, &p, &aid);double ans = 0, c = p, q = 1;for (int i = 1; i <= n; i++) {if (i < aid) c *= (1 - p);q *= (1 - p);}while (c > tmp) {ans += c;c *= q;}printf("%.4lf\n", ans);}return 0;}
- 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 ? 概率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 ?
- uva10056 - What is the Probability ?(概率是多少)
- 10056 - What is the Probability ?
- no such partition grub rescue的解决方案
- linux限制用户登录(ROOT及普通账户),禁止ping
- 浅谈ListView中组件的复用
- 60个开发者不容错过的免费资源库
- 【Android学习笔记】Android中Intent的应用方法探索
- uva 10056 - What is the Probability ?(概率)
- muduo网络库学习之Exception类、Thread 类封装中的知识点(重点讲pthread_atfork())
- 网狐、6878 您所填写的推荐人不存在或者填写错误,请检查后再次注册
- linux小程序
- Senior Software Engineer - 2013/10/28
- 千万不能返回局部变量的引用??
- 大数据量,海量数据 处理方法总结
- Web前端黑客技术揭秘 笔记5
- 本例主要实现任意删除及增1和补缺序联动操作,实际应用与数据库,这里用新建表做实例。