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
/*题意:给你n个黑球,向里面放一个红球,游戏规则:不放回往出取,先取都红球者赢,先手容易赢输出1,后手容易赢输出2,赢的概率相同输出0*/
/*思路:刚开始就觉得概率为1/n+1/(n-1) + 1/(n-2)......,仔细想想你每次的概率都是在之前没有赢的前提上的 那么假设n=3,那么最多共取m=4次,先手取也就是第1,3,后手取第2,4次,那么先手取这两次赢的概率分别1/4, 3/4 * 2/3 *1/2, 后手赢得概率分别为3/4 * 1/3, 3/4 * 2/3 *1/2 *1, 那么也就是发现其实每次取得概率都一样,那么总数m为偶数先手后手取得次数相同赢得概率相同,总数m为奇数那么先手取得次数多一次,那么概率相较后手概率大了1/m,则发现规律n为奇数输出0,n为偶数输出1*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
int n;
while(scanf("%d", &n) != EOF){
if(n & 1)
printf("0\n");
else
printf("1\n");
}
return 0;
}