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 ...
随机推荐
- 《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇06:计分》
6.计分 计分概述: 分值计量直接反应玩家在游戏中获得的成就感.因此,计分系统在游戏中显得尤为重要,有的反应在直接获取的分数上,有的反应在杀敌数量上等. 计分原理: 原理图,如图6-1所示. 图6-1 ...
- C语言的指针移位问题
先贴代码 #include <stdio.h> int main(void) { double a[]={1.1,2.2,3.3}; unsigned int b,c,d; b=& ...
- JAVA使用jdbc连接MYSQL简单示例
以下展示的为JAVA使用jdbc连接MYSQL简单示例: import java.sql.DriverManager; import java.sql.ResultSet; import java.s ...
- cocos2d-x图片变灰或者变亮
//根据现有CCSprite,变亮和变灰 CCSprite* FlyLeaf::graylightWithCCSprite(CCSprite* oldSprite,bool isLight) { ...
- (转)在iOS中使用icon font
http://ued.taobao.org/blog/?p=8579 在开发阿里数据iOS版客户端的时候,由于项目进度很紧,项目里的所有图标都是用最平常的背景图片方案来实现.而为了要兼容普通屏与Ret ...
- stm32f407 定时器 用的APB1 APB2 及 定时器频率
上午想要用Timer10做相对精确的延时功能,但是用示波器发现实际延时数值总是只有一半,百思不得其解.仔细查阅各处资料结合实际研究后对stm32f407的14个定时器的时钟做一个总结: 下面来源: h ...
- labview多个并行循环同时退出
labview中停止并行的循环 问题: 在labview中我如何停止两个并行的循环?我使用一个局部变量,但是当我停止程序执行后,第二次不能运行程序.我该如何解决这个问题呢? 解答: 你使用局部变量来 ...
- curl用法
简介 curl是一个和服务器交互信息(发送和获取信息)的命令行工具,支持DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, L ...
- 【LINUX】编程笔记
a storage class can only be specified for objects and functions extern修饰一个struct报错,错误原因如上,C++中存储类修 ...
- spark结合 Openfire服务器,发送聊天消息
1.下载OpenFire服务器,进行安装,参考http://www.cnblogs.com/hoojo/archive/2012/05/17/2506769.html 2.程序运行客户端:下载客户端代 ...