2016 ICPC大连赛区 hdu5978 To begin or not to begin

【达梦8】多实例监视集群的部署测试 确认监视器具有状态确认和自动接管两个功能。在数据守护系统的故障自动切换模式下,必须部署一个确认监视器,否则在出现数据库故障时,会导致数据库服务中断。DM 提供了两种确认监视器的配置形式,分别为单实例和多实例。但是当单实例确认监视器故障时,无法继续进行集群的故障自动接管和备库故障确认,影响正常使用,故提供了多实例确认监控器来进一步提高集群的高可用性。在多实例确认监视器中,只有一个实例作为确认监视器提供服务,其它实例作为备库存在而不提供服务。 阅读详情


To begin or not to begin

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 229    Accepted Submission(s): 175


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.
 

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
  
1 2
 

Sample Output
  
0 1
 

Source
 

Recommend
wange2014   |   We have carefully selected several similar problems for you:   5981  5979  5977  5976  5975 
 
题意:给k个黑球,1个红球,谁先拿到红球谁就赢,问先手赢的几率大还是后手赢的几率大或者一样大。

思路:这是个简单的概率问题,第n回合抽到红球的几率一定等于1/(k+1),那么赢的几率=拥有的回合数*(1/(k+1)),如果k为奇数,那么两边回合一样所以几率一样大,如果k为偶数那么必定先手的有多一个回合的机会,所以几率更大,下面给代码:

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
typedef long long LL;
using namespace std;
#define maxn 1005
#define ll l,mid,now<<1
#define rr mid+1,r,now<<1|1
#define lson l1,mid,l2,r2,now<<1
#define rson mid+1,r1,l2,r2,now<<1|1
int main(){
    int k;
    while(~scanf("%d",&k)){
        if(k&1)
            printf("0\n");
        else
            printf("1\n");
    }
}


2026零成本私有化:OpenClaw一键搭建Discord/Telegram智能机器人,数据不出本地,永久免费替代ChatGPT 如果内置的功能不能满足你的需求,你可以很容易地添加自己的自定义工具。public string Description => "查询指定城市的天气";// 调用天气API获取天气信息return $"city今天的天气是晴,温度25度";// 注册工具今天北京的天气怎么样?大模型的选择很重要:不要盲目追求大参数的模型。对于大多数场景来说,7B参数的模型已经足够用了,而且速度快,内存占用低。上下文长度不要设置太大:上下文长度越大,内存占用越高,推理速度越慢。 阅读详情

相关推荐

【学习笔记】人群归因分数 PAF 以及combined PAF

人群归因风险比例(Population Attributable Fraction,PAF)是一个流行病学指标,它估计了在总体中,如果能消除一个特定的危险因素,能预防多少百分比的疾病或健康结果。简单来说,PAF回答的是:“如果没有这个风险因素,总体中会有多少病例是可以避免的?

weixin_53499537的博客 4901

HDU 5980 && 2016ICPC大连 J: Find Small A

题意: 一个int型占4个字节,一个char型占1个字节,也就是说可以将一个int型“拆成“”4个char型,如果拆完之后其中一个同等于字母'a',则说明这个int型“包含”1个字母'a',给你n个int型数,问这n个数总共“包含”多少个字母'a' 对每个整数不停地右移8位,每移动一次判断当前余数是不是97就好,是就+1 #include int main(void) { int

加载中... 590

ANSYS 12.1避坑全记录:当Win7+VMware14遇到FLEXlm报错时的自救指南

本文详细介绍了在Windows 7和VMware14环境下安装和运行ANSYS 12.1时遇到的FLEXlm报错问题及其解决方案。通过虚拟机技术隔离时间同步问题,提供从环境配置到许可证管理的完整指南,帮助用户稳定运行这一老旧版本的工程仿真软件。

tt34567的博客 644

The 2016 ACM-ICPC Asia Dalian Regional Contest---题解

A - Wrestling Match(二分图染色/2-set/dfs瞎搞均可)  题意: Nowadays, at least one wrestling match is held every year in our country. There are a lot of people in the game is “good player”, the rest is “bad playe...

AAAAAAAC的博客 537

Linux中Hadoop 集群搭建

零、下载Hadoop: http://archive.cloudera.com/cdh5/cdh/5/?tdsourcetag=s_pctim_aiomsg 一、集群规划: 搭建的 hadoop 集群由 3 台服务器组成,分别叫做 master,salve1 和 slave2。其中 master 作为主节点,slave1 和 slave2 作为从节点。 二、网络配置: 1.查看 3 个节点的主机名...

白墨的小白博客 3992

innovus 命令每日精要 | 掌控Innovus布线的利器——setNanoRouteMode详解

在数字IC后端设计的复杂世界里,布线优化是至关重要的一步。今天,我来给大家深入讲解Innovus工具中setNanoRouteMode命令的精妙之处,让你轻松驾驭布线策略,提升设计质量。setNanoRouteMode是Innovus中用于配置NanoRoute绕线行为的关键命令。通过其丰富的参数,你可以精细控制布局后阶段的绕线策略、信号完整性优化、工艺适配及设计规则修复等流程。下面,我将按功能分类总结其核心选项,并针对不同场景给出建议。

weixin_50820814的博客 3528

oracle导出用户表数据库,Oracle导入/导出某个用户下的数据库

导出exp用户名/密码@数据库实例owner=用户名file=文件存储路径例如:exp MM/123456@ORCL owner=MM file=F\abcd.dmp导入imp用户名/密码@数据库fromuser=用户名touser=用户名file=d:\cu.dmp ignore=y例如:imp MM/123456@ORCL fromuser=MM touser=SZZM file=F:\tes...

weixin_32816613的博客 1774

Oracle EBS 寄销/VMI(1)-->基础设置

名词解释:     BPA:一揽子采购协议     BPR:一揽子发放     SR:来源补充规则     ASL:合格供应商列表     VMI: 供应商管理库存     寄售(Consignment)是把货物放在客户那里,客户要用的时候才付款的库存,一般是指卖方把

陈显平的专栏-Oracle EBS 1万+

hdu5978(概率思维题)

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 wh...

small__snail__5的博客 771

WPF中使用TreeView封装组合控件TreeView+DataGrid

wpf的功能非常强大,很多控件都是原生的,但是要使用TreeView+DataGrid的组合,就需要我们自己去封装实现。功能如上图所示, 目前基本上把常用的样式都实现了,购买源码后,可以自行修改样式。本文源码效果如下,(搞了好几天,的确有难度,所以源码也收费,便宜,赚点辛苦费)第一种:技术的选择是TreeView(也就是本文的演示)。这2个图都是第三方控件自带的,并且都是收费使用。首先说明一下,实现上面的效果,有3种方法。本文演示的是使用TreeView的实现。第二种:技术的选择是DataGrid。

故里2130 1650

【AUTOSAR-IpduM】-2.2-创建并配置一个接收RX的(Multiplexed-I-PDU)多路复用

案列背景: 在CFG中配置一个发送TX的(Multiplexed-I-PDU)多路复用Frame。 目录 1 在Arxml中创建一个发送的多路复用Frame 2 CFG导入带多路复用Frame的ARXML 2.1 CFG中提示的错误Error 2.2 如何解决CFG中提示的错误Error 3 结尾 <--返回「Autosar_BSW高阶配置」总目录--> <--返回「Autosar_BSW高阶配置」专栏主页--> <--返回「个人博客」首页--&g..

「汽车电子助手」的博客 1570

2016 ICPC大连赛区 [Cloned] H - 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 wh...

qq_42712462的博客 272

网络变更:APIC 节点替换

Fabric Name,Controller ID,TEP Address Pool 等信息必须相同;如果故障设备是 APIC1 还需要重新配置管理密码。此过程可能需要 10 分钟左右,在此期间目标 APIC 可能在 Available/Unavailable 状态翻滚。APIC 获取 TEP 地址后,进入 fully-fit。通过 CLI 以及配置的密码登录目标 APIC。

m0_54931486的博客 321

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/Others) Total Submission(s): 63    Accepted Submission(s): 44 Problem Description A b

In my way 923

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

2016ICPC大连站 H - 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

Irish_Moonshine的博客 462

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

2016 ICPC Dalian 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 gent

chimp10的博客 230

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

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/Others) Total Submission(s): 1061    Accepted Submission(s): 689 Problem Description A

DlPF_C的博客 504

HDU5978水题

题意: 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 playe...

Ivan_zcy的博客 441

hdu 5978 To begin or not to begin

点击打开题目链接 判断奇偶。。。。。。。。超级大水题。 #include using namespace std; int main(){ int n; while(~scanf("%d",&n)){ if(n&1) printf("0\n"); else printf("1\n"); } return 0;

zoro_n的博客 560

HDU 5978 To begin or not to begin (简单博弈--找规律)

大体题意: 给你k 个黑球和1个红球,两个轮流抽,抽到红球算赢,问先手赢的概率大还是后手大,还是概率相等? 思路: 写几个小的数手算一下 就看到规律了。 如果k 是偶数的话,那么先手的概率是 ((n+2)/3)/(n+1)  大于后手的概率 输出1 如果k 是奇数的话,那么先手后手概率都是1/2. #include #include #include using namespac

aozil_yang的博客 1058

2019省赛训练-N+6

http://acm.sdibt.edu.cn/vjudge/contest/view.action?cid=2234#overview A -Wrestling Match Sample Input 5 4 0 0 1 3 1 4 3 5 4 5 5 4 1 0 1 3 1 4 3 5 4 5 2 Sample Output NO YES 题意:多组样例,第一行给出4个数n...

ZCY的博客 259

Codeforces 399B Red and Blue Balls(数论)

题目链接:Codeforces 399B Red and Blue Balls 题目大意:在一个竖着的盒子里,有若干个球,给出球都颜色。每次将最上面的蓝色球上面的红色球取出,然后将该蓝色球换成红色,上面补上蓝色球。问说最少要多少次操作可以使得全部球都是红色的。 解题思路:其实就是一个二进制数,注意要用long long。 #include #include #in

不慌不忙、不急不躁 1680

HDU 5978 icpc 大连 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/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description A box c

窦小雨的小点子 896

HDU5978(签到题)

code:#include<cstdio> int main() { int n; while(scanf("%d",&n)!=EOF) { if(n&1) { printf("0\n"); } else { printf("1\n");

Cai_Haiq的博客 521

HDU 5978 && 2016ICPC大连 H: To begin or not to begin

题意: 黑色盒子里有n个白球,1个红球,两个人轮流取球,先取出红球的胜利 对于不同的n,先手优势输出1,劣势输出2,平等输出0 n=1,显然概率为1/2,平等 n=2,第一发取到白球概率是2/3也就是说2/3的概率让对面面对n=1的情况,你输的概率为2/3*1/2=1/3,有优势 n=3,第一发取到白球概率是3/4也就是说3/4的概率让对面面对n=2的情况,你输的概率为3/4*2

加载中... 607

HDU-5978-思维+概率

https://vjudge.net/contest/166094#problem/H 猜测样例写的过了。。没怎么搞明白概率什么鬼。 看题解。 k个黑球,1个红球,问你取红,先手是否有优势。 什么鬼的优势。。就是赢得概率 没一回合概率都是 1/(k+1),如果是奇数,那么概率相同。(奇数是偶数个球啊-.-) 偶数就一样。。#include <iostream> #include <cst

天与云与山与水 615
上一篇: 2016 ICPC大连赛区 hdu5980 Find Small A
下一篇: 2016 ICPC大连赛区 hdu5974 Convex
overload1997
博客等级 码龄11年 328粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值