HDU 5978 icpc 大连 To begin or not to begin
来源:互联网 发布:linux文件复制命令 编辑:程序博客网 时间:2024/05/16 13:46
To begin or not to begin
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0
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
题目大意:
给出 n 个黑球,一个红球。
抽出红球胜利。如果先手有优势 输出 1 没有优势 输出 2 机会均等输出 0
思路:
可以手算出前几项的概率。
胆大的现在就可以猜答案了。奇数0 偶数 1
不放心的话,就打个表。
AC代码:
#include<bits/stdc++.h>using namespace std;int main(){ int T; int n; while(~scanf("%d",&n)) { if(n&1) { cout<<0<<endl; } else cout<<1<<endl; }}
0 0
- HDU 5978 icpc 大连 To begin or not to begin
- HDU 5978 && 2016ICPC大连 H: 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(概率)
- hdu 5978 To begin or not to begin
- ICPC 2016 DALIAN H To begin or not to begin
- HDU5971 To begin or not to begin
- hdoj 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(概率+规律)
- To Begin
- perl---use lib or BEGIN{ } to add directory to @INC
- Begin to sell
- leetcode(E)two sum
- [hdu 5973 Game of Taking Stones] Wythoff Game+大数运算
- Linux UDP网络编程
- 数据结构中的树
- 总结37
- HDU 5978 icpc 大连 To begin or not to begin
- Unity3D自学笔记——UGUI背包系统(二)UI设计实现及数据绑定
- POJ 3133 Manhattan Wiring
- LeetCode(55)Jump Game
- Floyd-Warshall(弗洛伊德)算法求所有节点对的最短路径问题
- Junit单元测试Spring读取classes或者WEB-INF目录下的配置文件
- Oracle建表空间、用户、标、约束
- 【PHP开发】国外程序员收集整理的 PHP 资源大全
- java环境变量安装(PS:保存一个网址(里面有后续学习所需要的ADT,SDK,Android Studio.....))