Calendar Game
http://poj.org/problem?id=1082
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 4820 | Accepted: 2273 | 
Description
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
Output
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的更多相关文章
- Java 时间类-Calendar、Date、LocalDate/LocalTime
		
1.Date 类 java.util.Date是一个"万能接口",它包含日期.时间,还有毫秒数,如果你只想用java.util.Date存储日期,或者只存储时间,那么,只有你知道哪 ...
 - Js: Extensible Calendar  Examples
		
http://ext.ensible.comhttps://github.com/bmoeskau/Extensiblehttps://github.com/TeamupCom/extensibleh ...
 - Calendar类
		
Calendar类 注意:根据日历规则,如果想要这个月减去5天,那么则为: add(Calendar.Day,-5) 成员方法: public int get(int field):返回给定日历段的值 ...
 - This month Calendar
		
package fourth;import java.text.DateFormatSymbols;import java.util.*;public class CalendarTest { pub ...
 - calendar的一些操作
		
一.通过分析日期函数,根据日期进行一系列操作,例如:我们需要知道2个时间段中所有的日期等等. 由于Calendar 类是一个抽象类,因此我们不能通过new来获取该对象的实例.我们可以通过其类方法 ge ...
 - java-String Date Calendar之间的转换
		
1.Calendar 转化 String Calendar calendat = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDa ...
 - jQuery Ion.Calendar 日期/日历
		
在线实例 实例演示 默认 实例演示 每周第一天 实例演示 输入框插件 实例演示 HTML data 属性 实例演示 回调函数1 实例演示 回调函数2 使用方法 <div id="cal ...
 - [java] 可视化日历的实现(基于Calendar类 )
		
写在前面 博文安排顺序如下 1.写在前面 2.源码 3.思路 4.相关知识 该小程序是对Date类及其相关类的复习 要求如下图:实现可视化日历 实现思路 1.先从键盘输入指定格式的字符串(str)2. ...
 - WPF 点击Calendar后,需要点击两次按钮
		
主面板上有一个Calendar控件,点击选择了日期后,如果点击确认按钮,需要点击两次.这个问题的解决方法如下: private void calendar1_PreviewMouseUp(ob ...
 - 【JAVA】JDK -Calendar 遇到的 一个坑
		
Calendar是JDK 1.1增加的类 最近使用了下Calendar发现几个很让人抓狂的问题 源码: public final static int SUNDAY = 1; public final ...
 
随机推荐
- sys.default_constraints
			
作为默认定义且 sys.objects.type = D 的每个对象在表中各对应一行, 该默认定义是作为 CREATE TABLE 或 ALTER TABLE 语句的一部分创建的, 而不是作为 CRE ...
 - webSocket vnc rfb
 - openstack instance snapshort
			
从下面的截图 高手应该能够看到openstack基于snapshort的 实例的 备份策略了!!!! 从下面某张截图你也能看到用openstack snapshort备份 也是 不太理想的,首先从“磁 ...
 - JavaScript——以简单的方式理解闭包
			
闭包,在一开始接触JavaScript的时候就听说过.首先明确一点,它理解起来确实不复杂,而且它也非常好用.那我们去理解闭包之前,要有什么基础呢?我个人认为最重要的便是作用域(lexical scop ...
 - hadoop conf中xml文件修改
			
core-site.xml <?xml version="1.0"?><?xml-stylesheet type="text/xsl" hre ...
 - 扩展KMP题目
			
hdu4333 /* 题意:字符串s[0..n-1],每次把最后一个字符放到前面,求形成的字符串比最初串分别小,相同,大于的个数 因为是为了练习扩展KMP所以肯定是扩展KMP, 为了循环方便,在后面复 ...
 - jstat用法
			
jstat(JVM Statistics Monitoring Tool)是用于监视虚拟机各种运行状态信息的命令行工具.它可以显示本地或者远程虚拟机进程中的类装载.内存.垃圾收集.JIT编译等运行数据 ...
 - linux下的调试工具ltrace与strace
			
ltrace能够跟踪进程的库函数调用,它会显现出哪个库函数被调用,而strace则是跟踪程序的每个系统调用. 下面是一个ltrace与strace的对比 1)系统调用的输出对比 我们用输出he ...
 - ASP.NET MVC中Session以及处理方式
			
转载原地址 http://www.cnblogs.com/darrenji/p/3951065.html
 - opencv 模板匹配与滑动窗口(单匹配) (多匹配)
			
1单匹配: 测试图片: code: #include <opencv\cv.h> #include <opencv\highgui.h> #include <open ...