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. <Araxis Merge>快速一览文件的比较与合并

    重要的文件比较与合并特性在下面都指出了.对每个特性的说明性内容在下面可以找到. 注意:只有双向的比较/合并被展示了,专业版的Merge还支持三向的比较/合并. 1.文件夹比较按钮 单击这个工具栏按钮会 ...

  2. windows下安装和配置Weka

    Weka是一款免费的,非商业化的,基于java环境下的开源的机器学习以及数据挖掘软件.Weka里含有各种数据挖掘工具:数据预处理,分类与回归,聚类,关联规则和可视化工具. 一.安装weka 我们首先需 ...

  3. jsp文件上传、下载

    一.文件上传 上传文件是Web开发中经常要用到的功能:例如在基于B/S的人事信息管理系统中上传照片,在新闻发布系统中上传图片等等.....要实现文件上传功能,就需要综合利用java中的文件输入和输出相 ...

  4. Type datetime2 is not a defined system type - Entity Framework 摘自网络

    "Type datetime2 is not a defined system type" Solution: 把edmx 改为 ProviderManifestToken=&qu ...

  5. centos6.4 安装erlang

    erlang官网: http://www.erlang.org 下载程序去年:

  6. hdu 1689 Just a Hook

    http://acm.hdu.edu.cn/showproblem.php?pid=1698 Just a Hook Time Limit: 4000/2000 MS (Java/Others)    ...

  7. java数字保留两位小数四舍五入

    import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberFormat; public c ...

  8. HDU 5266 pog loves szh III (LCA)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5266 题目就是让你求LCA,模版题.注意dfs会栈溢出,所以要扩栈,或者用bfs写. #pragma ...

  9. HDU 3664 Permutation Counting (DP)

    题意:给一个 n,求在 n 的所有排列中,恰好有 k 个数a[i] > i 的个数. 析:很明显是DP,搞了好久才搞出来,觉得自己DP,实在是太low了,思路是这样的. dp[i][j]表示 i ...

  10. 转载“启动\关闭Oracle数据库的多种方法”--来自百度#Oracle

    启动\关闭Oracle数据库的多种方法 启动和关闭oracle有很多种方法. 这里只给出3种方法: l         Sql*plus l         OEM控制台 l         Wind ...