Problem Description
Kate and Emilico are playing a game. There are 33 integers a,b,ca,b,c. It is guaranteed that there exists a non-degenerate triangle whose side lengths are a,b,ca,b,c respectively. The game goes as follows. Players take turns in decreasing a certain positive integer on one of the 33 integers. If there doesn't exist a non-degenerate triangle whose side lengths are a,b,ca,b,c after a player's operation, the player loses.
Kate goes first. If both of them play optimally, will Kate win?
Input
The first line of input contains one integer TT (1\le T\le 10^41≤T≤104), indicating the number of test cases.
For each test case, the only line contains 33 integers a,b,ca,b,c (1\le a,b,c\le 10^91≤a,b,c≤109). It is guaranteed that there exists a non-degenerate triangle whose side lengths are a,b,ca,b,c respectively.
Output
For each test case, if Kate will win, output \texttt{Win}Win in a single line. Otherwise, output \texttt{Lose}Lose in a single line.
Sample Input
3
2 2 3
2 3 4
5 3 4
Sample Output
Win
Lose
Win
题意: 给出3个整数a,b,c,保证能够构成一个三角形,两人轮流操作,每次可以将其中一个数字缩小,必须保证缩小后仍能构成三角形,当某人不能进行操作时视为失败。
分析: 设两个状态,L态:(a-1) xor (b-1) xor (c-1) == 0和W态:(a-1) xor (b-1) xor (c-1) != 0,对于L态,L态一定是一个合法的三角形,因为(a-1) xor (b-1) == c-1,所以(a-1) + (b-1) >= c-1,也就是a + b > c。当a等于1时显然L态是一个必败态,当a大于1时总可以减少其中一个数值来得到一个合法三角形,缩小后L态也就转变为了W态。对于W态有(a-1) xor (b-1) != (c-1)这一不等式,可以分为(a-1) xor (b-1) > (c-1)和(a-1) xor (b-1) < (c-1),但无论哪种情况都可以得出(b-1) xor (c-1) < a-1,(c-1) xor (a-1) < b-1,(b-1) xor (a-1) < c-1这三式中至少一个式子成立,假设成立的是(b-1) xor (c-1) < a-1,那么可以变形为(a-1) xor (a-1) xor (b-1) xor (c-1) < a-1,也就可以将a减小至(a-1) xor (a-1) xor (b-1) xor (c-1) + 1,这样就从W态转为了L态,由于L态一定是个合法三角形,所以这次转变也是合法的。L态一定是必败态和转向W态中的一种,W态又总能转为L态,所以L态一定是必败态,W态一定是必胜态,最后只需要判断一下a,b,c是L态还是W态即可。
具体代码如下:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
using namespace std;
signed main()
{
int T;
cin >> T;
while(T--){
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if((a-1)^(b-1)^(c-1))//必胜态
puts("Win");
else//必败态
puts("Lose");
}
return 0;
}