HDU 5978 To begin or not to begin(概率)
来源:互联网 发布:苹果电脑视频制作软件 编辑:程序博客网 时间:2024/05/16 14:30
To begin or not to begin
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1226 Accepted Submission(s): 790
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
Source
2016ACM/ICPC亚洲区大连站-重现赛(感谢大连海事大学)
题意:
n个黑球,1个红球,两个人依次摸,摸到红球算赢。问你先摸好还是后摸好,还是都一样。
POINT:
可知当n是奇数时,两个人摸的机会一样。输出0
n偶数时,先摸的可以多摸一次,输出1。
#include <iostream>#include <stdio.h>#include <math.h>using namespace std;const double PI = acos(-1.0);int main(){ int k; while(~scanf("%d",&k)){ if(k&1) printf("0\n"); else printf("1\n"); } return 0;}
阅读全文
0 0
- HDU 5978 To begin or not to begin(概率)
- HDU 5978 To begin or not to begin(概率)
- HDU 5978 To begin or not to begin (概率数学)
- hdu 5978 To begin or not to begin(概率期望)
- HDU 5978 To begin or not to begin(水题)
- HDU5978 To begin or not to begin(概率+规律)
- hdu 5978 · To begin or not to begin【概率题】【手速题】
- HDU 5978 icpc 大连 To begin or not to begin
- hdu 5978 To begin or not to begin
- hdu 5978 To begin or not to begin
- HDU 5978 To begin or not to begin (简单博弈--找规律)
- HDU5971 To begin or not to begin
- hdoj 5978 To begin or not to begin
- HDU 5978 && 2016ICPC大连 H: To begin or not to begin
- ICPC 2016 DALIAN H To begin or not to begin
- To Begin
- perl---use lib or BEGIN{ } to add directory to @INC
- Begin to sell
- 常用软件
- 10.1更 spring boot 登录拦截(附上代码)
- 编写程序,打印出N阶魔阵(N个奇数)
- 关于MyBatis中的@param的讲解
- Java基础小知识(一)
- HDU 5978 To begin or not to begin(概率)
- (二十一)Animator 实例 —— 刷鲜花效果
- 第四周--3(3)
- 构建乘积数组
- Anaconda环境配置
- 小记-面试时对MVC的理解
- vue简介
- python3.6基础学习记录(二)
- 线段树基础