Threads 1004

describe

Adam and Eve play a game where they randomly select a date from 1900.1.1 to 2001.11.4. Then they take turns operating on this date:

1 : Add 1 to the day of the date, for example, 1900.1.1 becomes 1900.1.2

2: Add 1 to the month, for example: 1900.1.1 to 1900.2.1

If the number of days exceeds the number of days, the date will be changed to the 1st day of the next month. Months exceeding 12 change to January of the following year. And when the second operation is performed, if there is such a date: 1900.1.31, it becomes 1900.2.31. Such an operation is illegal and we do not allow it. And all operations take into account the provisions of the calendar and leap years.

Whoever changes the date to 2001.11.4 first wins.

In every game, Adam operates first and asks him if he has a winning strategy?

Format

input format

a test point. multiple sets of data.

The first row is the number of data sets.

The next line XYZ represents X year Y month Z day

output format

The output "YES" or "NO" indicates whether Adam has a winning strategy.

Example 1

Sample input 1

3
2001 11 3
2001 11 2
2001 10 3

Sample output 1

YES
NO
NO

hint

It is recommended to calculate everything first ^_^



1. Topic analysis:

First of all, for the selected date, two people take turns to perform any one of the two operations on the date, that is to say, each operation of each person can choose any one of the two operations at will, instead of sticking to and a certain order. To figure this out, I was misunderstood in the first place.

Secondly, pay attention to the rules of the game, the date and month will automatically advance to one; dates similar to 1.31 are not allowed to operate on the month.

Finally, the question is whether there is a winning strategy for a given date, that is, after selecting a strategy and performing several operations, Adam added the date to 2001.11.14

2. Ideas:

As a hint, work out all the cases first.

At first I thought it was telling me to use the stupidest method to calculate and store all possible results, and then judge the input data one by one. Only after seeing the analysis of the big man, I understood that it was another meaning.

Because the person who added the date to 2001.11.4 first wins, so Adam fails if he chooses 11.4, and pushes forward 11.3, 11.1, 10.30...and 10.4, 8.4.... At this time (month+day) It is an even number; and 11.2, 10.31, 9.4, etc. are not allowed, at this time (month+day) is an odd number. That is, the two operations are operations performed on month and day, then in general, the parity of (month+day) changes sequentially, so we can think that when (month+day) is an even number, Adam can succeed, (month When +day) is odd, Adam will fail, regardless of year (orz, the person who gave the question kneeled).

So will special cases be used? some. Because (month+day) is an even number, it is possible to win, so only need to consider those special points in which (month+day) is an odd number.

2.29: ①2.29->3.1 Because 3.1 can be won, so 2.29 loses

          ②2.29->3.29 Because 3.29 can be won, so 2.29 loses

          So 2.29 loses

8.31: Since September has only 30 days, operations can only be performed on dates.

          8.31->9.1 9.1 can win, so 8.31 loses

10.31, same as 12.31

9.30: 9.30->10.1 Because 10.1 must lose, 9.30 can win

11.30 Same

So there are two special cases, namely: 9.30 and 11.30


#include <iostream>

using namespace std;

intmain()
{
    int N;
    cin>>N;
    int year,month,day;
    for(int i=0;i<N;i++)
    {
        cin>>year>>month>>day;
        if(month==9&&day==30)
            cout<<"YES"<<endl;
        else if(month==11&&day==30)
            cout<<"YES"<<endl;
        else if((month+day)%2==0)
            cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Guess you like

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