hdu 1079 Calendar Game 博弈

简介:

 

    题目就是寻找有无必胜策略

    一开始看错题意了,一直想用dp预处理下,结果发现就是简单的逻辑判断。

    无论向后一天还是向后一月,均会改变奇偶性,除了4.30,9.30,11.30和非润年的2.28,在几个特殊日期中向后可能会改变奇偶性。

    目标日期为11.4,偶数。

    因此,无特殊日期时奇数必胜

    而如果先手是偶数,其必然不会进入特殊日期,因为一旦奇偶改变,必胜变为必输……

    如果先手为奇数,因为不存在必改变奇偶性的日期,所以进入特殊日期后也无法改变奇偶性,保持原状态……

    因此只有在初始日期为特殊日期,先手才有改变奇偶使自己必胜的机会。


/*
author:jxy
lang:C/C++
university:China,Xidian University
**If you need to reprint,please indicate the source**
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#define INF 1E9
using namespace std;
bool leap(int year)
{
    if(year%4==0&&(year%100||year%400==0))return 1;
    return 0;
}
int main()
{
    int T=0;
    scanf("%d",&T);
    int y,m,d;
    while(T--)
    {
        scanf("%d%d%d",&y,&m,&d);
        if((m+d)%2==0||(d==30&&(m==11||m==9||m==4))||(d==28&&m==2&&!leap(y)))puts("YES");
        else puts("NO");
    }
}


目录
相关文章
|
8月前
codeforces 304 B. Calendar
就是给你两个日期,让你求两个日期之间差多少天。 我先算出两个日期分别是公元多少天,然后相减得到结果。
22 0
[POJ3678] Katu Puzzle | 2-SAT 入门
Description Katu Puzzle is presented as a directed graph G ( V , E ) with each edge e ( a , b ) labeled by a boolean operator op (oneofAND,OR,XOR) and an integer c ( 0 ≤ c ≤ 1 ) . One Katu is solvable if one can find each vertex Vi a value X i ( 0 ≤ X i ≤ 1 )