http://poj.org/problem?id=1082

Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 4820   Accepted: 2273

Description

Adam and Eve enter this year's ACM International Collegiate Programming Contest. Last night, they played the Calendar Game, in celebration of this contest. This game consists of the dates from January 1, 1900 to November 4, 2001, the contest day. The game starts by randomly choosing a date from this interval. Then, the players, Adam and Eve, make moves in their turn with Adam moving first: Adam, Eve, Adam, Eve, etc. There is only one rule for moves and it is simple: from a current date, a player in his/her turn can move either to the next calendar date or the same day of the next month. When the next month does not have the same day, the player moves only to the next calendar date. For example, from December 19, 1924, you can move either to December 20, 1924, the next calendar date, or January 19, 1925, the same day of the next month. From January 31 2001, however, you can move only to February 1, 2001, because February 31, 2001 is invalid. 
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.

Input

The input consists of T test cases. The number of test cases (T ) is given in the first line of the input file. Each test case is written in a line and corresponds to an initial date. The three integers in a line, YYYY MM DD, represent the date of the DD-th day of MM-th month in the year of YYYY. Remember that initial dates are randomly chosen from the interval between January 1, 1900 and November 4, 2001.

Output

Print exactly one line for each test case. The line should contain the answer "YES" or "NO" to the question of whether Adam has a winning strategy against Eve. Since we have T test cases, your program should output totally T lines of "YES" or "NO".
 

Sample Input

3
2001 11 3
2001 11 2
2001 10 3

Sample Output

YES
NO
NO 搜索+DP+博弈
 #include <stdio.h>
#include <memory.h> int isWin[][][];
int maxDay[] = {,,,,,,,,,,,,}; int judge(int y, int m, int d)
{
int win; if(y > || (y == &&(m > || (m == && d > )))) return ;
if(y == && m == && d == ) return ;
if(isWin[y][m][d] == -)
{
win = ;
if(m != )
{
if(d <= maxDay[m+] || (d == && m == && (y % ) == && y != ))
if(judge(y, m+, d) == ) win = ;
}
else if(judge(y+, , d) == ) win = ; if(win==)
{
if(d < maxDay[m])
win = -(judge(y, m, d+));
else if(m != )
win = -(judge(y, m+, ));
else
win = -(judge(y+, , ));
}
isWin[y][m][d] = win;
}
return (isWin[y][m][d]);
} int main()
{
int iCase;
int m, d, y; memset(isWin, , sizeof(isWin));
scanf("%d", &iCase);
while(iCase--)
{
scanf("%d%d%d", &y, &m, &d);
if(judge(y - , m, d) == )
printf("YES\n");
else
printf("NO\n");
}
return();
}

Calendar Game的更多相关文章

  1. Java 时间类-Calendar、Date、LocalDate/LocalTime

    1.Date 类 java.util.Date是一个"万能接口",它包含日期.时间,还有毫秒数,如果你只想用java.util.Date存储日期,或者只存储时间,那么,只有你知道哪 ...

  2. Js: Extensible Calendar Examples

    http://ext.ensible.comhttps://github.com/bmoeskau/Extensiblehttps://github.com/TeamupCom/extensibleh ...

  3. Calendar类

    Calendar类 注意:根据日历规则,如果想要这个月减去5天,那么则为: add(Calendar.Day,-5) 成员方法: public int get(int field):返回给定日历段的值 ...

  4. This month Calendar

    package fourth;import java.text.DateFormatSymbols;import java.util.*;public class CalendarTest { pub ...

  5. calendar的一些操作

    一.通过分析日期函数,根据日期进行一系列操作,例如:我们需要知道2个时间段中所有的日期等等. 由于Calendar 类是一个抽象类,因此我们不能通过new来获取该对象的实例.我们可以通过其类方法 ge ...

  6. java-String Date Calendar之间的转换

    1.Calendar 转化 String Calendar calendat = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDa ...

  7. jQuery Ion.Calendar 日期/日历

    在线实例 实例演示 默认 实例演示 每周第一天 实例演示 输入框插件 实例演示 HTML data 属性 实例演示 回调函数1 实例演示 回调函数2 使用方法 <div id="cal ...

  8. [java] 可视化日历的实现(基于Calendar类 )

    写在前面 博文安排顺序如下 1.写在前面 2.源码 3.思路 4.相关知识 该小程序是对Date类及其相关类的复习 要求如下图:实现可视化日历 实现思路 1.先从键盘输入指定格式的字符串(str)2. ...

  9. WPF 点击Calendar后,需要点击两次按钮

    主面板上有一个Calendar控件,点击选择了日期后,如果点击确认按钮,需要点击两次.这个问题的解决方法如下:     private void calendar1_PreviewMouseUp(ob ...

  10. 【JAVA】JDK -Calendar 遇到的 一个坑

    Calendar是JDK 1.1增加的类 最近使用了下Calendar发现几个很让人抓狂的问题 源码: public final static int SUNDAY = 1; public final ...

随机推荐

  1. 《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇06:计分》

    6.计分 计分概述: 分值计量直接反应玩家在游戏中获得的成就感.因此,计分系统在游戏中显得尤为重要,有的反应在直接获取的分数上,有的反应在杀敌数量上等. 计分原理: 原理图,如图6-1所示. 图6-1 ...

  2. C语言的指针移位问题

    先贴代码 #include <stdio.h> int main(void) { double a[]={1.1,2.2,3.3}; unsigned int b,c,d; b=& ...

  3. JAVA使用jdbc连接MYSQL简单示例

    以下展示的为JAVA使用jdbc连接MYSQL简单示例: import java.sql.DriverManager; import java.sql.ResultSet; import java.s ...

  4. cocos2d-x图片变灰或者变亮

    //根据现有CCSprite,变亮和变灰 CCSprite* FlyLeaf::graylightWithCCSprite(CCSprite* oldSprite,bool isLight) {    ...

  5. (转)在iOS中使用icon font

    http://ued.taobao.org/blog/?p=8579 在开发阿里数据iOS版客户端的时候,由于项目进度很紧,项目里的所有图标都是用最平常的背景图片方案来实现.而为了要兼容普通屏与Ret ...

  6. stm32f407 定时器 用的APB1 APB2 及 定时器频率

    上午想要用Timer10做相对精确的延时功能,但是用示波器发现实际延时数值总是只有一半,百思不得其解.仔细查阅各处资料结合实际研究后对stm32f407的14个定时器的时钟做一个总结: 下面来源: h ...

  7. labview多个并行循环同时退出

    labview中停止并行的循环 问题: 在labview中我如何停止两个并行的循环?我使用一个局部变量,但是当我停止程序执行后,第二次不能运行程序.我该如何解决这个问题呢? 解答:  你使用局部变量来 ...

  8. curl用法

    简介 curl是一个和服务器交互信息(发送和获取信息)的命令行工具,支持DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, L ...

  9. 【LINUX】编程笔记

      a storage class can only be specified for objects and functions extern修饰一个struct报错,错误原因如上,C++中存储类修 ...

  10. spark结合 Openfire服务器,发送聊天消息

    1.下载OpenFire服务器,进行安装,参考http://www.cnblogs.com/hoojo/archive/2012/05/17/2506769.html 2.程序运行客户端:下载客户端代 ...