2016ICPC-大连 To begin or not to begin (简单思维)
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.InputMultiple 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.
OutputFor 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 在每一次概率相同的情况下,拿的次数多的人赢的概率大。至于每一次赢概率为什么相同,就跟概率论里的买彩票一样,先买后买概率一样。
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
const double pi=acos(-1.0);
int n,d,x;
int main()
{
while(~scanf("%d",&n))
{
if (n%==) printf("1\n");
else printf("0\n");
}
return ;
}
2016ICPC-大连 To begin or not to begin (简单思维)的更多相关文章
- hdu 5978 To begin or not to begin(概率,找规律)
To begin or not to begin Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java ...
- HDU 5978 To begin or not to begin
题目:HDU 5978 To begin or not to begin 思路: 题目意思是说:给出n个黑球,一个红球,拿到红球的人胜利.如果先手有优势的输出 1 ,没有优势的输出 2 ,机会均等则输 ...
- 2016icpc大连站总结(呐 如果把这段回忆,起个名字珍藏起来,叫它“宝物”应该很合适吧)
10月15号一早乘飞机去了大连,12点这样到了海事大学,是一所很大的学校,来往的学生有些穿着海军服.然后我们到体育馆领了衣服,就去食堂吃午饭,中间有段小插曲,就是我们队的餐券没领..不过那里的负责人让 ...
- 【HDOJ5978】To begin or not to begin(概率)
题意:有k个黑球和1个红球,两个轮流抽,抽到红球算赢,问先手赢的概率大还是后手大还是相等 k<=1e5 思路:手算前几项概率 大胆猜想 #include<cstdio> #inclu ...
- hdu 5869 Different GCD Subarray Query BIT+GCD 2016ICPC 大连网络赛
Different GCD Subarray Query Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
- 事务操作(BEGIN/COMMIT/ROLLBACK/SAVE TRANSACTION)
BEGIN TRANSACTION 标记一个显式本地事务的起始点. BEGIN TRANSACTION 使 @@TRANCOUNT 按 1 递增. BEGIN TRANSACTION 代表一点,由连接 ...
- JSFのAjaxタグのoneventでbegin/complete/successを使う
PrimeFacesに慣れてしまって.通常のHTMLタグでの記述方法がわからなかったりする点があった…ので.メモ. Ajaxでリクエスト送信のタイミングやレスポンスが戻るタイミングに何らか(JavaS ...
- Sql Server 中事务(begin tran/commit tran/rollback tran)的用法
ALTER PROCEDURE [dbo].[Proc_Test_commit1] @result int output, --成功 1; 失败 0 @message nvarchar ...
- (转)SQL流程控制语句学习(二):begin…end if…else case
1.begin…end 语法: begin {sql语句或语句块} end 注意:begin 和end要成对使用 2.if…else 语法: if 布尔表达式 {sql语句或语句块} else 布 ...
随机推荐
- CSU OJ 1340 A Sample Problem
Description My girlfriend loves 7 very much, she thinks it is lucky! If an integer contains one or m ...
- java XML(可扩展标记语言)
XML 是EXtensible Markup Language的缩写,它是一种类似于HTML的标记语言,称为可扩展标记语言,传输数据而不是显示数据,可以自定义标签,具有自我描述性是一种通用的数据交换格 ...
- Fiddler 抓包工具总结【转载】
原博主连接在文章底部 Fiddler是一个蛮好用的抓包工具,可以将网络传输发送与接受的数据包进行截获.重发.编辑.转存等操作.也可以用来检测网络安全.反正好处多多,举之不尽呀!当年学习的时候也蛮费劲, ...
- [luogu P1552] [APIO2012]派遣
[luogu P1552] [APIO2012]派遣 题目背景 在一个忍者的帮派里,一些忍者们被选中派遣给顾客,然后依据自己的工作获取报偿. 题目描述 在这个帮派里,有一名忍者被称之为Master.除 ...
- LaTeX技巧10:LaTeX数学公式输入初级入门
LaTeX最强大的功能就是显示美丽的数学公式,下面我们来看这些公式是怎么实现的. 1.数学公式的前后要加上 $ 或 \( 和 \),比如:$f(x) = 3x + 7$ 和 \(f(x) = 3x + ...
- 2-MAVEN 基本命令
MVN的基本命令 mvn package:打包 >生成了target目录 >编译了代码 >使用junit测试并生成报告 >生成代码的jar文件 >运行jar包: java ...
- 读入excle
可以输出到csv(逗号间隔,具体搜索csv格式). csv可以在excel中直接导入. 也可以用system函数调用ssconvert从csv转xlsx:system("ssconvert ...
- shutil 模块
import shutil #用于简化文件操作的模块 # f1 = open(r"D:\上海python全栈4期\day20\7.shutil模块.py","rb&quo ...
- 和的java程序
- 阿里云服务器上安装mysql的详细步骤
阿里云安装mysql (1)下载mysql安装包,去mysql官网下载对应的包 mysql数据库官方下载网址: https://downloads.mysql.com/archives/commu ...