HDU
来源:互联网 发布:mac vi怎么保存退出 编辑:程序博客网 时间:2024/06/02 02:53
To begin or not to begin
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1061 Accepted Submission(s): 689
Problem Description
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.
Input
Multiple test cases (number of test cases≤50), process till end of input.
For each case, a positive integer k (1≤k≤10^5) is given on a single line.
For each case, a positive integer k (1≤k≤10^5) is given on a single line.
Output
For each case, output:
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.
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.
Sample Input
12
Sample Output
01
简单的概率计算,最后发现当k是奇数时,先手后手获胜概率是相同的,当k是偶数时,先手获胜的几率大些。
#include<stdio.h>int main(){ int k; while(scanf("%d",&k)!=EOF) { if(k%2==0) printf("%d\n",1); else printf("%d\n",0); }}
阅读全文
0 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- hdu 1269 迷宫城堡(Tarjan算法)
- 初始化img-loader
- 解题报告:HDU_6136:Death Podracing (优先队列+循环链表)
- 人脑拆机三部曲:为什么我支持马斯克,而人类应该畏惧人工智能
- VS常用快捷键
- HDU
- 记录ArcGIS Server打印服务出现的问题
- linux实验楼学习笔记9
- ios在uiwebview执行js方法
- java读取文件
- 【算法】3、堆排序
- Python在大数据分析及机器学习中的兵器谱
- HDU 4578——Transformation
- java.io.NotSerializableException错误解决方法(com.landray.sso.client.EKPSSOUserData)