A player wins the game when he/she exactly reaches the date of November 4, 2001. If a player moves to a date after November 4, 2001, he/she looses the game.
Write a program that decides whether, given an initial date, Adam, the first mover, has a winning strategy.
For this game, you need to identify leap years, where February has 29 days. In the Gregorian calendar, leap years occur in years exactly divisible by four. So, 1993, 1994, and 1995 are not leap years, while 1992 and 1996 are leap years. Additionally, the years ending with 00 are leap years only if they are divisible by 400. So, 1700, 1800, 1900, 2100, and 2200 are not leap years, while 1600, 2000, and 2400 are leap years.
3 2001 11 3 2001 11 2 2001 10 3
YES NO NO
题意:两个人轮流玩游戏,每个人可以把日期进行转移,转移规则:
1.可以转移到当前日期的下一天,比如3.31~4.1
2可以转移到下个月的这一天,比如3.20~4.20,但是如果下个月没有这一天就不能进行第二种转移,比如3.31只能转移到4.1,因为4月没有31天
3.如果A恰好移动到2001.11.4那么A赢,如果移动到2001.11.4之后则输
给你初始日期(只能在1900.1.1~2001.11.4)求先移动的人的胜负态
思路:
有31天的月份:1,3,5,7,8,10,12
30天的月份:4,6,9,11
奇葩月:2
先从2001.11开始看,这个月只有4天,且每一天只有第一种转移态,那么可以知道1和3号是必胜态,2和4号是必败态,故2001.11月是奇胜
再向前看10月,因为10.5~10.31的转移态只有第一种转移态,那么根据推断,10.31为必败,所以5~31的这些天里偶数的天为必胜态,奇数必败。
再看10月的1~4,对于4来说下一个可以到5和11.4,所以必胜,对于3可以到11.3和10.4所以必败,所以1~4也是偶数必胜奇数必败,故10月是偶数必胜,奇数必败。
再看9月,因为9.30可以转到10.1和10.30,为了胜利就选择到10.1故9.30必胜,然后看9.29,可以转到10.29和9.30,同样为了胜利转到10.29,但是再看9.28,无论转到9.29还是10.28都会输,所以9.28是必败,同理9月的1~27都是奇胜偶败,加上28,29,30可以得出结论,9月的1~29号都是奇胜偶败,且9.30也为胜。
再看八月,8.31只能到9.1,故为败,8.30可以到8.31故为胜,8.29可以到9.29和8.30,而这两种都会输,所以8.29是输,则1~28号的推理过程相似所以8月是奇败偶胜。
这样可以按照相同的方法推出:
7月:奇胜偶败
。。。。。。。
3月:奇胜偶败
再来看2月,如果有29天,则对于2.29可以到3.29和3.1,都会输,所以2.29败,2.28可以到2.29故会赢。所以这种情况是奇败偶胜
如果只有28天,2.28可以到3.28故会赢,2.27可以到2.28和3.27,但都会输,所以这种情况是奇败偶胜
所以2月无论是有29天还是有28天都是奇败偶胜
1月:奇胜偶败
前一年:
12月:奇败偶胜
11月:30可以到12.1,所以胜利,29可以到12.29所以胜利,28可以到29和12.28,但是都会输,所以11月的1~29都是奇胜偶败,且30也会胜利
所以对于任意一个日期(除了9.30和11.30)只要月份+天数为偶数就会胜利,否则失败。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int y, m, d;
scanf("%d%d%d", &y, &m, &d);
if((m==9||m==11)&&d==30) //特判
{
printf("YES\n");
continue;
}
if((m+d)&1)
printf("NO\n");
else
printf("YES\n");
}
return 0;
}