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

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

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

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

大體題意:

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 青川县| 冕宁县| 吴江市| 阿坝县| 阳曲县| 天津市| 故城县| 无为县| 千阳县| 哈尔滨市| 惠州市| 东方市| 新郑市| 淮滨县| 崇义县| 新建县| 安丘市| 铁岭县| 兰坪| 隆子县| 桓台县| 安仁县| 鄂托克前旗| 微博| 九龙县| 宣化县| 新平| 大渡口区| 五峰| 会宁县| 博湖县| 昌黎县| 准格尔旗| 太仆寺旗| 读书| 阿尔山市| 潍坊市| 信丰县| 汤阴县| 临泉县| 宜昌市|