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 布 ...
随机推荐
- svn: 提交终止
今天我遇到了svn 的问题 svn: 提交终止: “/var/www/modelfinance/modules/incomereport/views/purchase” 处于冲突状态 冲突状态搞的我 ...
- java集合的实现细节--ArrayList和LinkedList
ArrayList和LinkedList的实现差异 List代表一种线性表的数据结构,ArrayList则是一种顺序存储的线性表,ArrayList底层采用动态数组的形式保存每一个集合元素,Link ...
- 关于int8_t,uint8_t.....等数据类型的理解
实习中,今天在看公司源码的时候,发现前辈给的代码都是这样的 typedef int8_t int8; typedef uint8_t uint8; typedef int16_t int16; typ ...
- GitHub学习三-远程版本库更新与提交
1.远程版本库更新 一般来说,将本地与远程相关联之后,首先将数据从远程更新下来再上传比较好. 输入 git pull origin master 如果新建版本库的话勾选了初始化包含readme.md, ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(2)-Datauard部署篇
1. primary库设置dataguard相关参数 1.1. 强制primay库在任何状态下必须记录日志 SYS@userdata>select FORCE_LOGGING from v$ ...
- time_wait 和 close_wait
tcp 四次握手状态图: 使用以下命令统计 tcp 连接信息: netstat -n |awk '/^tcp/ {++S[$NF]} END {for (a in S) print a, S[a]}' ...
- cmp的值到底是0还是1还是-1的问题
返回值不局限于这三个数返回负数,表示第一个参数小于第二个参数返回整数,表示第一个参数大于第二个参数返回0,表示他们相等
- 把旧系统迁移到.Net Core 2.0 日记(8) - EASYUI datagrid+ Dapper+ 导出Excel
迁移也没太大变化,有一个, 之前的Request.QueryString 是返回NameValueCollection, 现在则是返回整个字符串. 你要改成Request.Query[“key”] 直 ...
- js 正则常用函数 会正则得永生
正则表达式作为一种匹配处理字符串的利器在很多语言中都得到了广泛实现和应用,web开发本质上是处理字符串(服务端接受请求处理后拼接字符串作为响应,这在早期的CGI编程中最明显,然后客户端解析字符串进行渲 ...
- ubuntu下唤醒或休眠远程计算机
ubuntu让我明白,没有什么完美的东西,要想完美必须付出代价.要么花时间折腾,要么花时间赚钱买系统. 人生也是一样,所以不要期待什么完美.哪有那么好的人,在合适的时间合适的地点让你遇见,还对你有感觉 ...