Take a stone gameTime
limit:MS
Memory Limit:10000KB
64bit IO Format:%i64d &%i64u SubmitStatusPracticePOJ 1067Appoint Description:System Crawler (2015-03-14)
Description
There are two piles of stones, the quantity is arbitrary, can be different. The game began with two people taking turns to take stones. The game rules, each time there are two different ways, one can take away any number of stones in any heap, and two can take the same number of stones in both piles. Finally, the stones are all taken out as the winner. Now give the number of the initial two piles of stones, if it's your turn to take it first, assume that both sides adopt the best strategy and ask whether you are the winner or the loser.
Input
The input contains several lines that represent the initial condition of several kinds of stones, each of which contains two nonnegative integers a and B, indicating the number of stones, A and B, not greater than 1,000,000,000.
Output
The output corresponds to a number of lines, each containing a number 1 or 0, or 1 if you are the winner, or 0 for the other.
Sample Input
2 18 44 7
Sample Output
010
This is a naked Wei Zoff game, proof of what the weak is not understand, first proved eight theorems, and then introduced the formula according to this theorem, interested in the giant can go to Baidu Encyclopedia to see, Orz.
In this talk about the conclusion of Witzov game: Two if all use the correct operation, then face the non-singular situation, the first to win the winner;
See here for details---------->ACM game theory Summary
#include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include < iostream> #include <algorithm> #include <queue> #include <map> #include <set>using namespace Std;int Main () { int a,b,k,tmp; while (~SCANF ("%d%d", &a,&b)) { if (a>b) swap (A, b); k=b-a; tmp= (int) k* (1.0+SQRT (5.0))/2; if (tmp==a) printf ("0\n"); else printf ("1\n"); } return 0;}
POJ 1067-Take the Stone game (Witzov)