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 布 ...
随机推荐
- vivadio关联notepad++的关键式
D:\Program Files\Notepad++\notepad++.exe +[line number] [file name]
- 五、Oracle的常识点
1.Oracle中使用rownum来进行分页,这个是效率最好的分页方法 select * from ( ) 2.Oracle的索引使用 创建索引: create index index_name on ...
- [转]java异常中Exception捕获不到的异常
一 概念 众所周知java提供了丰富的异常类,这些异常类之间有严格的集成关系,分类为 父类Throwable Throwable的两个子类Error和Exception Exception的两个子类C ...
- from…import 语句
- win7下使用U盘安装双系统(Ubuntu-17)
1.首先下载Ubuntu镜像文件,下载地址:http://mirrors.neusoft.edu.cn/ 2.下载 U盘操作系统安装工具- Universal USB Installer ,下载地址: ...
- 在项目中使用 SCSS
背景概述 1. CSS预处理器 css预处理器定义了一种新的编程语言,编译后成正常的CSS文件.为CSS增加一些编程的特性,无需考虑浏览器的兼容问题,让CSS更加简洁,适应性更强,可读性更佳,更易于代 ...
- css3 居中(推荐弹性盒模型方式)
参考 http://www.zhihu.com/question/20774514 http://caibaojian.com/demo/flexbox/align-items.html 例子:ht ...
- MyBatis 为什么需要通用 Mapper ?
一.通用 Mapper 的用途 ? 我个人最早用 MyBatis 时,先是完全手写,然后用上了 MyBatis 代码生成器(简称为 MBG),在使用 MBG 过程中,发现一个很麻烦的问题,如果数据库字 ...
- Spring Boot 如何极简入门?
Spring Boot已成为当今最流行的微服务开发框架,本文是如何使用Spring Boot快速开始Web微服务开发的指南,我们将创建一个可运行的包含内嵌Web容器(默认使用的是Tomcat)的可运行 ...
- datatime 模块
import datetime # 这个是一个包 里面包含 对时间的处理 对日期的处理datetime.date # 日期相关datetime.time # 时间相关 # 获取当前详细时间print( ...