hdu5978(概率思维题)
来源:互联网 发布:长江航运能力 知乎 编辑:程序博客网 时间:2024/05/21 06:36
A box contains black balls and a single red ball. Alice and Bob draw balls from this box without replacement, alternating after each draws until the red ball is drawn. The game is won by the player who happens to draw the single red ball. Bob is a gentleman and offers Alice the choice of whether she wants to start or not. Alice has a hunch that she might be better off if she starts; after all, she might succeed in the first draw. On the other hand, if her first draw yields a black ball, then Bob’s chances to draw the red ball in his first draw are increased, because then one black ball is already removed from the box. How should Alice decide in order to maximize her probability of winning? Help Alice with decision.
For each case, a positive integer k (1≤k≤10^5) is given on a single line.
1, if the player who starts drawing has an advantage
2, if the player who starts drawing has a disadvantage
0, if Alice's and Bob's chances are equal, no matter who starts drawing
on a single line.
12
01
/*题意:给你n个黑球,向里面放一个红球,游戏规则:不放回往出取,先取都红球者赢,先手容易赢输出1,后手容易赢输出2,赢的概率相同输出0*/
/*思路:刚开始就觉得概率为1/n+1/(n-1) + 1/(n-2)......,仔细想想你每次的概率都是在之前没有赢的前提上的 那么假设n=3 赢得概率为 1/3, (2/3) *(1/2), (1/3)*1,即每次概率与取不取出无关。则发现规律为奇数输出1,偶数输出0*/
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int main(){ int n; while(scanf("%d", &n) != EOF){ if(n & 1) printf("0\n"); else printf("1\n"); } return 0;}
0 0
- hdu5978(概率思维题)
- HDU5978(签到题)
- HDU5978 To begin or not to begin(概率+规律)
- hdu4503(概率的逆向思维)
- lightoj-1104-Birthday Paradox【概率】(思维)
- CFgym:Magic Artifact(概率期望 & 思维)
- HDU-5978-思维+概率
- Light OJ:1104 Birthday Paradox(数学概率+思维)
- 统计思维(实例4)——概率密度函数
- 算法概率思维导图
- 算法概率思维导图
- 三门问题之概率思维
- 生活中的统计概率思维
- 蓝桥杯(概率题)
- 蓝桥杯(概率题)
- 概率题(1)
- 2017 秦皇岛CCPC M题 Safest Buildings(概率+思维+计算几何)
- 统计思维:程序员数学之概率统计(第2版)——互动出版网
- C++多线程 互斥锁 信号量 事件 临界区
- centos配置hadoop伪分布式环境
- 自定义设置hr的颜色
- java基础改学C++(八)运算符重载
- Python中用print方法向文件中写入内容
- hdu5978(概率思维题)
- 汪国新关公百图精品展在台北国父纪念馆隆重举行
- 数据结构(8)之堆
- Dubbo实战之具体应用
- 关于PScs6无法拖入图片的解决
- Android开发之RecyclerView实现点击事件和长按事件
- InputStreamReader和OutputStreamWriter的用法
- MySQL小技巧总结(持续更新)
- css 中 position属性的深入学习