码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 5978 To begin or not to begin

时间:2017-05-02 10:02:06      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:otto   hand   memory   better   eth   amp   mem   order   aws   

To begin or not to begin

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 765    Accepted Submission(s): 492


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.
 

 

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.
 

 

Sample Input
1 2
 

 

Sample Output
0 1
 

 

Source
 

 

Recommend
 
 
 
 

hdu 5978 To begin or not to begin

标签:otto   hand   memory   better   eth   amp   mem   order   aws   

原文地址:http://www.cnblogs.com/bofengyu/p/6794505.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!