#P1512. 伊甸园日历游戏
伊甸园日历游戏
Description
Adam and Eve play a game that starts from a date chosen uniformly at random from to . They then take turns applying one of the following operations to the current date:
- Add to the day. For example, becomes .
- Add to the month. For example, becomes .
If the day exceeds the number of days in the current month, the date rolls over to the st day of the next month. If the month exceeds , it rolls over to January of the next year. Moreover, when performing operation 2, if the resulting date would be invalid (for example, becoming ), the operation is illegal and not allowed. All operations must respect calendar rules, including leap years.
Whoever first changes the date to exactly wins. If you overshoot the specified date, it does not count as a win.
Adam always moves first. For the given starting date, determine whether he has a winning strategy.
Input Format
- The first line contains an integer , the number of test cases.
- Each of the next lines contains three integers , , , indicating year , month , and day .
Output Format
For each test case, output YES or NO indicating whether Adam has a winning strategy.
3
2001 11 3
2001 11 2
2001 10 3
YES
NO
NO
Hint
2024/1/31 Added a set of hack testdata.
Translated by ChatGPT 5
京公网安备 11011102002149号