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

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

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

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

大體題意:

給你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  


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 安龙县| 夏邑县| 闻喜县| 安顺市| 舟山市| 黔东| 中山市| 老河口市| 连城县| 张北县| 团风县| 漯河市| 大港区| 隆德县| 洛扎县| 隆昌县| 德江县| 秀山| 金塔县| 桂东县| 彰化县| 苍溪县| 沈阳市| 南充市| 福泉市| 淅川县| 乃东县| 渭南市| 泽州县| 东海县| 西华县| 砚山县| 澄江县| 霍林郭勒市| 贺州市| 济阳县| 巴青县| 洪雅县| 察哈| 洛扎县| 古蔺县|