您的位置:首页 > 其它

HDOJ1079Calendar Game (找规律博弈)

2013-07-10 11:14 465 查看
其实这道题从找规律这方面来考虑的话还是比较容易一点的

题目大意是:

     两个家伙在区域赛前夕闲的无聊,然后玩一种无限纠结的游戏,随即给定一个日期,每次只能移动day OR month而且如果下一个月没有当前day的话       ,      你就不能移动month,比如1月31日,你只能移动day
使其到2月1日,而不能移动月让其到达2月31日嗯,现在Adam需要你来找一个必胜策略       !到达      2001.11.4日就不能移动

我们可以找一下规律:

必败                  必胜

11.4                   11.3

11.2                   11.1

10.31                 10.30

…………

10.5                   10.4

…………

10.1                   9.30

                         9.29(可以跳到10.29)

…………

9.2                  9.1

8.31                8.30

………………

12.1              11.30

…………

这样的话,我们可以看出,通过一年的周期循环,可以得到胜态和年份木有关系,可以看到比胜态的月份+日子为偶数(除过两个特殊的9.30和11.30),所以我们就可以这样写咯

#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
using namespace std;
int min(int a, int b)
{
if(a<=b)
return a;
return b;
}
int max(int a, int b)
{
if(a>=b)
return a;
return b;
}
double min(double a, double b)
{
if(a<=b)
return a;
return b;
}
double max(double a, double b)
{
if(a>=b)
return a;
return b;
}
int main()
{
int y , m, d;
int t;
scanf("%d", &t);
while(t--)
{
scanf("%d%d%d", &y, &m, &d);
if((m+d)%2==0 || (d==30&& (m==9||m==11)))
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
不过标准的PN分析还没有看懂呢,我找了一个大家可以去看看,
http://blog.csdn.net/surfacedust/article/details/6687946
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  博弈 找规律 PN