Take a stone game
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 4442 Accepted Submission (s): 2306
Problem description has two piles of stones, which can be different in quantity. 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 inputs contain 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.
The output outputs correspond to several lines, each containing a number 1 or 0, or 1 if you are the winner, or 0 for the other.
Sample Input2 18 44 7
Sample Output010
Sourcenoi
Recommendll | We have carefully selected several similar problems for you:1404 1536 1517 1524 1729 Witzov game (Wythoff game): There are two piles of various items, two people take turns From a heap or at the same time from the two piles to take the same number of items, the provisions of at least one at a time, more than open, the last to win the light.
In this case it is quite complicated. We use (AK,BK) (AK≤BK, k=0,1,2,...,n) to indicate the number of items and call it the situation , if a face (0,0), then A has been lost, this situation we call the singular situation. The first few strange situations are: (0,0), (3,5), (4,7), (6,10), (8,13), (9,15), (11,18), (12,20).
As you can see, A0=b0=0,ak is the smallest natural number not seen before, and bk= AK + K.
There is a fixed judgment formula, if a== (b-a) (sqrt (5.0+1)/2.0), then (A, b) is a singular point;
1#include <stdio.h>2#include <math.h>3 intMain ()4 {5 intt, N, M;6 while(~SCANF ("%d%d", &n, &m))7 {8 if(N >m)9 {Tent =N; Onen =m; Am =T; - } -t = M-N; the if(n = = (int)((Double) t* (sqrt (5.0)+1.0)/2.0)) -printf"0\n"); - Else -printf"1\n"); + } - return 0; +}
Hangzhou Electric 1527--Take the stone game (Witzov game)