国产探花免费观看_亚洲丰满少妇自慰呻吟_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  


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 安徽省| 德令哈市| 依安县| 酒泉市| 商城县| 仲巴县| 西城区| 田林县| 廉江市| 潢川县| 贞丰县| 民乐县| 清镇市| 平昌县| 巩留县| 剑阁县| 龙海市| 离岛区| 彰化市| 江口县| 桐柏县| 巴里| 汉源县| 突泉县| 宁德市| 大港区| 德惠市| 应用必备| 奇台县| 浏阳市| 西吉县| 华阴市| 津南区| 道孚县| 湖南省| 福鼎市| 商都县| 兴安县| 通榆县| 教育| 绥棱县|