• hdu 2147 kiki's game


    kiki's game

    Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/1000 K (Java/Others)
    Total Submission(s): 6476    Accepted Submission(s): 3845


    Problem Description
    Recently kiki has nothing to do. While she is bored, an idea appears in his mind, she just playes the checkerboard game.The size of the chesserboard is n*m.First of all, a coin is placed in the top right corner(1,m). Each time one people can move the coin into the left, the underneath or the left-underneath blank space.The person who can't make a move will lose the game. kiki plays it with ZZ.The game always starts with kiki. If both play perfectly, who will win the game?
     
    Input
    Input contains multiple test cases. Each line contains two integer n, m (0<n,m<=2000). The input is terminated when n=0 and m=0.

     
    Output
    If kiki wins the game printf "Wonderful!", else "What a pity!".
     
    Sample Input
    5 3
    5 4
    6 6
    0 0
     
    Sample Output
    What a pity!
    Wonderful!
    Wonderful!
     
    Author
    月野兔
     
    Source
     
    解题:利用P/N态,作图
    hdu-2147:kikis game - 陈年往事 - 我学acm 的博客

    P点:就是P个石子的时候,对方拿可以赢(自己输的)

    N点:就是N个石子的时候,自己拿可以赢

    现在关于P,N的求解有三个规则

    (1):最终态都是P

    (2):按照游戏规则,到达当前态的前态都是N的话,当前态是P

    (3):按照游戏规则,到达当前态的前态至少有一个P的话,当前态是N

     以上内容摘自http://blog.163.com/gditacmfeng@yeah/blog/static/13702062420100160358818/

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <cmath>
     5 #include <algorithm>
     6 #include <climits>
     7 #include <vector>
     8 #include <queue>
     9 #include <cstdlib>
    10 #include <string>
    11 #include <set>
    12 #define LL long long
    13 #define INF 0x3f3f3f3f
    14 using namespace std;
    15 
    16 int main(){
    17     int n,m;
    18     while(scanf("%d%d",&n,&m),n+m){
    19         n %= 2;
    20         m %= 2;
    21         if(n && m) puts("What a pity!");
    22         else puts("Wonderful!");
    23     }
    24     return 0;
    25 }
    View Code
  • 相关阅读:
    Swift -- Swfit 笔记
    web -- CSS 图片宽高不固定的垂直居中方法
    web -- Angularjs 笔记2
    web -- Angularjs 笔记
    web -- Angularjs 备忘录应用
    Swift -- swift 函数代码
    Swift -- 创建空数组和空字典
    Linux -- FresBSD的镜像文件说明
    Linux -- ubuntu下安装程序的三种方法
    Linux -- Ubuntu 命令2
  • 原文地址:https://www.cnblogs.com/crackpotisback/p/3869816.html
Copyright © 2020-2023  润新知