To begin or not to begin

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

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
 
 
 

给出 n 个黑球,一个红球。

抽出红球胜利。如果先手有优势 输出 1 没有优势 输出 2 机会均等输出 0

思路:可以手算出前几项的概率。

胆大的现在就可以猜答案了。奇数0 偶数 1

不放心的话,就打个表。

 #include<iostream>
#include<stdio.h>
#include<math.h>
#include <string>
#include<string.h>
#include<map>
#include<queue>
#include<set>
#include<utility>
#include<vector>
#include<algorithm>
#include<stdlib.h>
using namespace std;
#define maxn 200100
#define maxm 200005
#define rd(x) scanf("%d", &x)
#define rd2(x, y) scanf("%d%d", &x, &y)
#define mod 1000000007 int main()
{
int k;
while(~scanf("%d", &k)){
if(k%) printf("0\n");
else printf("1\n");
}
return ;
}
 

hdu 5978 To begin or not to begin(概率,找规律)的更多相关文章

  1. HDU 2147 kiki's game (简单博弈,找规律)

    kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/1000 K (Java/Others)Total ...

  2. HDU 5795 A Simple Nim (博弈 打表找规律)

    A Simple Nim 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5795 Description Two players take turns ...

  3. HDU 5753 Permutation Bo (推导 or 打表找规律)

    Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

  4. HDU 5795 A Simple Nim(SG打表找规律)

    SG打表找规律 HDU 5795 题目连接 #include<iostream> #include<cstdio> #include<cmath> #include ...

  5. HDU 2672 god is a girl (字符串处理,找规律,简单)

    题目 //1,1,2,3,5,8,13,21,34,55…… //斐波纳契数列 #include<math.h> #include<stdio.h> #include<s ...

  6. HDU 2897 邂逅明下 (简单博弈,找规律)

    邂逅明下 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  7. HDU 4919 Exclusive or (数论 or 打表找规律)

    Exclusive or 题目链接: http://acm.hust.edu.cn/vjudge/contest/121336#problem/J Description Given n, find ...

  8. HDU 4861 Couple doubi (数论 or 打表找规律)

    Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a ...

  9. 2014 HDU多校弟八场H题 【找规律把】

    看了解题报告,发现看不懂 QAQ 比较简单的解释是这样的: 可以先暴力下达标,然后会发现当前数 和 上一个数 的差值是一个 固定值, 而且等于当前数与i(第i个数)的商, 于是没有规律的部分暴力解决, ...

  10. hdu - 6277,2018CCPC湖南全国邀请赛B题,找规律,贪心找最优.

    题意: 给出N个小时,分配这些小时去写若干份论文,若用1小时写一份论文,该论文会被引用A次,新写一篇论文的话,全面的论文会被新论文引用一次. 找最大的H,H是指存在H遍论文,而且这些论文各被引用大于H ...

随机推荐

  1. Qt隐式共享与显式共享

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/Amnes1a/article/details/69945878Qt中的很多C++类都使用了隐式数据共 ...

  2. 一段能瞬间秒杀所有版本IE的简单HTML代码

    许多人都非常讨厌InternetExplorer,在西方万圣节即将到来之际,让我们来看一个真正吓人的东西——如何用一段简单的HTML和CSS,将任何版本的IE搞死.我们只需要简单地打开任意文本编辑器, ...

  3. python setup.py install 报错:error: [WinError 3] 系统找不到指定的路径。: 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\PlatformSDK\\lib

    Outline 在通过 setup.py 安装python模块时,遇到了以下报错: # 执行 python setup.py install # 报错: error: [WinError 3] 系统找 ...

  4. 初级dba学习之路参考

    今天周一拖着疲惫的身躯 11点才离开公司,回到家估计写完这篇博客就要17号了. 一个人走在回家的路上,很黑,突然很多感触,一个人在北京拼搏,不敢停止学习的脚步,因为只要停下来就会感觉到孤独. 回顾一下 ...

  5. sql server等待类型

    sql server 各种等待类型-转 sql server各个等待类型及解决办法:https://www.sqlskills.com/help/waits/writelog/其他等待类型的描述和解决 ...

  6. Redis二(Hash操作)

    Hash操作 Hash操作,redis中Hash在内存中的存储格式如下图: hset(name, key, value) 1 2 3 4 5 6 7 8 9 # name对应的hash中设置一个键值对 ...

  7. Java读写.properties文件实例,解决中文乱码问题

    package com.lxk.propertyFileTest; import java.io.*; import java.util.Properties; /** * 读写properties文 ...

  8. network FAQ

    @1: 参考 ifconfig eth0之后IP总是自动清除,解决方法, 修改vim /etc/network/interfaces 然后执行sudo /etc/init.d/networking r ...

  9. Hadoop2.7.x中所有的DataNode都启动不了解决办法

    参考:Hadoop集群所有的DataNode都启动不了解决办法说明现象:我自己出现这个问题的原因是:自己在namenode格式化之后创建了一些文件,然后重新执行了namenode格式化导致的. 现象就 ...

  10. Java 基础总结(一)

    本文参见:http://www.cnblogs.com/dolphin0520/category/361055.html 1. String,StringBuffer,StringBuilder 1) ...