国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

HDU 5978 To begin or not to begin (簡單博弈--找規律)

2019-11-10 17:17:19
字體:
來源:轉載
供稿:網友

大體題意:

給你k 個黑球和1個紅球,兩個輪流抽,抽到紅球算贏,問先手贏的概率大還是后手大,還是概率相等?

思路:

寫幾個小的數手算一下 就看到規律了。

如果k 是偶數的話,那么先手的概率是 ((n+2)/3)/(n+1)  大于后手的概率 輸出1

如果k 是奇數的話,那么先手后手概率都是1/2.

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int main(){	int n;	while(~scanf("%d",&n)){		if (n & 1) puts("0");		else puts("1");	}	return 0;}

To begin or not to begin

Time Limit: 2000/1000 MS (java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 476    Accepted Submission(s): 316PRoblem DescriptionA 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 advantage2, if the player who starts drawing has a disadvantage0, if Alice's and Bob's chances are equal, no matter who starts drawingon a single line. Sample Input
12 Sample Output
01 Source2016ACM/ICPC亞洲區大連站-重現賽(感謝大連海事大學) Recommendwange2014   |   We have carefully selected several similar problems for you:  6014 6013 6012 6011 6010  


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 秦安县| 乐东| 江阴市| 沁源县| 汉阴县| 锡林郭勒盟| 曲周县| 拉萨市| 睢宁县| 始兴县| 巧家县| 河北区| 汽车| 顺义区| 天祝| 天峻县| 宾阳县| 邵阳市| 象山县| 天峻县| 巴彦县| 会宁县| 射洪县| 平舆县| 台中县| 灌阳县| 南溪县| 宁远县| 新密市| 恩施市| 五指山市| 界首市| 绥棱县| 屯门区| 七台河市| 竹山县| 三穗县| 图木舒克市| 林芝县| 健康| 景东|