[博弈论]Triangle Game 2022杭电多校第7场 1008

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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值