Nimes Game Bash Game +

Wang and colleagues like to play some games, they chose to play today take stones.

Rules of the game as follows: Total stack N stones, stones of known amount of each stack, and a predetermined number of good gravel stones per stack can be taken up (taking a minimum).

Two people take turns promoter, can select only N stones piled in a stack, take a certain amount of stone (take a minimum), and the number of stones is not taken more than the stones piled up to a predetermined number of sub-fetch good, etc. what people can not take the hour of midnight, says this person lost the game.

Take a single sub-ceiling assume every time Wang to take the stones, and the game both sides are extremely intelligent, and now give you heaps of stones, the number of each pile of stones and each stack stones provisions, please judge Wang can win .

Input
of the first line is an integer and T represents the number of test cases (T <100)
a first data line of each test is an integer N (1 <N <100) , N denotes total of the heap of stones, each subsequent row N row represents a pile of stones, in which each row has N rows two integer numbers m, n represents the total of m pebble stones stack, the stack takes a maximum of n stones. (0 <= m, n < = 2 ^ 31)
outputs
for each test case, the output can win Win represents Wang, Wang represents the output Lose inevitably lost.
Sample input
2
. 1
1000. 1
2
. 1. 1
. 1. 1
sample output
Lose
Lose
prompt
attention to the following set of test data
2
. 1. 1 
2 2
correct result should be Win
because Wang would take to start a second stack pebble stones in a state becomes
1 1
1 2
this state, no matter how the other party to take, Wang can win.

 1 #include <stdio.h>
 2  
 3 int bashi(int n, int m){
 4     return n % (m+1);
 5 }
 6  
 7 int main(){
 8     int t, num, n, m, ans;
 9     scanf("%d", &t);
10     while(t--){
11         scanf("%d", &num);
12         ans = 0;
13         while(num--){
14             scanf("%d%d", &n, &m);
15             ans ^= bashi(n, m);
16         }
17         printf(ans ? "Win\n" : "Lose\n");
18     }
19     return 0;
20 }

 

Guess you like

Origin www.cnblogs.com/pangbi/p/11516674.html