zoukankan      html  css  js  c++  java
  • 黑发黑眼 & hdu2147

    Description

    HJA 在和学弟下棋。棋盘的大小是 N*M 的,一开始在棋盘的右上角(1,M)有一枚棋子。 HJA 和学弟每次可以将这枚棋子向左、向下或者向左下移动一次。不能移动的人将会输掉比赛。自然, HJA 不想在学弟的面前输掉比赛,所以请告诉 HJA 如果 HJA 先手的话能够获得胜利吗?

    Solution

    考试的时候是打表找规律做的,考完了尝试证明了一下

    我们画一下 (PN)

    这里写图片描述

    可以发现,(n)(m) 只要有一个为偶数, (HJA) 就获胜。

    #include<cstring>
    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<vector>
    #include<cmath>
    using namespace std;
    
    #define N 100001
    #define rep(i, a, b) for (int i = a; i <= b; i++)
    #define drp(i, a, b) for (int i = a; i >= b; i--)
    #define fech(i, x) for (int i = 0; i < x.size(); i++)
    #define ll long long
     
    inline int read() {
        int x = 0, flag = 1; char ch = getchar(); while (!isdigit(ch)) { if (!(ch ^ '-')) flag = -1; ch = getchar(); }
        while (isdigit(ch)) x = (x << 1) + (x << 3) + ch - '0', ch = getchar(); return x * flag;
    }
    
    inline void write(int x) {
        if (!x) { putchar('0'); return; } if (x < 0) putchar('-'), x = -x;
        char buf[20] = ""; int top = 0; while (x) buf[++top] = x % 10 + '0', x /= 10; while (top) putchar(buf[top--]);
    }
    
    int n, m;
    
    int main() {
        while (scanf("%d%d", &n, &m) == 2 && n && m) {
            puts(((n & 1) && (m & 1)) ? "What a pity!" : "Wonderful!");
        }
        return 0;
    }
    
  • 相关阅读:
    WPF DelegateCommand 出现Specified cast is not valid
    WPF DelegateCommand 出现Specified cast is not valid
    WPF DelegateCommand 出现Specified cast is not valid
    win10 sdk 是否向下兼容
    win10 sdk 是否向下兼容
    win10 sdk 是否向下兼容
    PHP extract() 函数
    PHP end() 函数
    PHP each() 函数
    PHP current() 函数
  • 原文地址:https://www.cnblogs.com/aziint/p/8416409.html
Copyright © 2011-2022 走看看