nyoj 135 Take stones (2) (Nym game + limit number)

Take stones (2)

Time Limit: 3000  ms | Memory Limit: 65535  KB
Difficulty: 5
describe

Xiao Wang likes to play some small games with his colleagues, and today they chose to play fetch stones.

The rules of the game are as follows: There are N piles of stones, the number of stones in each pile is known, and the maximum number of stones that can be taken from each pile is specified (minimum 1).

Two people take turns to take stones, each time they can only choose one of the N piles of stones, take a certain number of stones (at least one), and the number of stones taken cannot be more than the specified maximum number of stones for the pile, etc. When a person cannot take a piece, it means that person has lost the game.

Assuming that Xiao Wang takes the stones first every time, and both sides of the game are absolutely smart, now we will give you the number of stones in the pile, the number of stones in each pile and the upper limit of single-taking stones in each pile, please judge whether Xiao Wang can win. .

enter
The first line is an integer T that represents the number of test data groups (T<100)
. The first line of each test data group is an integer N (1<N<100), which means there are N piles of stones, and each of the following N lines Represents a pile of stones, each of the N lines has two integers m, n indicates that there are m stones in the pile of stones, and the pile of stones can be selected at most n at a time. (0<=m,n<=2^31)
output
For each set of test data, output Win indicates that Xiao Wang can win, and output Lose indicates that Xiao Wang will inevitably lose.
sample input
2
1
1000 1
2
1 1
1 1
Sample output
Lose
Lose
In fact, when the number of acquisitions is not limited, it is also a=a%(a+1)=a, so this step is simplified
#include<stdio.h>
intmain()
{
	int t,n,a,b;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		int s=0;
		while(n--)
		{
			scanf("%d%d",&a,&b);
			a=a%(b+1);
			s=s^a;
		}
		if(s)
		printf("Win\n");
		else printf("Lose\n");
	}
	return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325939541&siteId=291194637