博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2016 ICPC大连赛区 [Cloned] H - To begin or not to begin
阅读量:3930 次
发布时间:2019-05-23

本文共 1406 字,大约阅读时间需要 4 分钟。

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

12

Sample Output

01

只分奇偶考虑 

“ 2,if the player who starts drawing has a disadvantage ”为干扰项 先取不可能吃亏

#include 
using namespace std;typedef long long ll;int k;int main(){ while (~scanf("%d",&k)) { if(k==1) printf("0\n"); else printf("1\n"); }}

 

转载地址:http://totgn.baihongyu.com/

你可能感兴趣的文章
外包管理
查看>>
项目管理师职业道德规范
查看>>
战略管理概述
查看>>
业务流程管理和重组
查看>>
知识管理
查看>>
项目整体绩效评估
查看>>
信息安全系统和安全体系
查看>>
信息系统安全风险识别与评估
查看>>
信息安全系统的组织管理
查看>>
项目时间管理脉络
查看>>
项目成本管理脉络
查看>>
项目质量管理脉络
查看>>
项目人力资源管理脉络
查看>>
项目沟通管理脉络
查看>>
项目风险管理脉络
查看>>
项目采购管理脉络
查看>>
项目管理总结
查看>>
java内存区域的分布
查看>>
JVM的GC是怎么折腾内存的
查看>>
Java跨平台的构思分析
查看>>