• UESTC_Little Deer and Blue Cat CDOJ 1025


    In DOTA, there are two Intellegence heroes. One is Enchantress, who is usually called Little Deer by Chinese players. The other is Storm Spirit, who is usually called Blue Cat by Chinese players.

    Well, in UESTC-ACM Team, there are two Intellegent team members. One is acerlawson, who is usually called God Li by others. The other is qzy, who is usually called Master Qiu by others.

    One day, qzy and acerlawson are arguing with each other about who is the best DOTA player in the team, so they want to play a game. The game is played in DOTA. However, the rule of the game is quite different from DOTA.

    In the game, acerlawson plays Little Deer, and qzy plays Blue Cat. They plays the game in turn, and acerlawson goes first. At frist, Little Deer has A HP, and Blue Cat has B HP. In each hero's turn, the hero can choose an integer P and attack the enemy. The enemy will lose P HP. Here P can be 1 or any prime number not greater than the enemy's HP. The one whose HP become 0 first will lose the game.

    As they are both intellegent, they will make the best choice to win this game. In another word, they will try to kill the other as early as possible.

    Your task is really simple: Given A and B, find out who will win this game.

    Input

    The first line is an integer T(1T1000), the number of test cases.

    Then T lines follows.

    Each line contains two integers A and B(1A,B108).

    Output

    For each test case, print God Li if acerlawson will win the game. Otherwise print Master Qiu.

    Sample input and output

    Sample InputSample Output
    3
    2 4
    4 4
    99999989 4
    Master Qiu
    God Li
    Master Qiu

    解题报告:

    注意到哥德巴赫猜想,任意大于2的偶数必能写成2个素数之和.

    so,偶数的情况我们就解决了,那么奇数了?,很显然我们可以得出一个结论:

    任意奇数HP的最多三下就GG(扣一点血转换成偶数)

    除去素数,那么奇数二下就死如何判断呢?

    ...do not ask me,i use dp prove that if (x-2) is a prime,he will die in twice

     1 #include <iostream>
     2 #include <cstring>
     3 #include <cstdio>
     4 #include <algorithm>
     5 #include <cmath>
     6 using namespace std;
     7 
     8 bool IsPrime(int x)
     9 {
    10   if (x <= 2)
    11    return true;
    12   int k = sqrt(x) + 1;
    13   for(int i = 2 ; i <= k ; ++ i)
    14    if ( !(x % i))
    15     return false;
    16   return true;
    17 }
    18 
    19 int main(int argc,char *argv[])
    20 {
    21   int Case;
    22   scanf("%d",&Case);
    23   while(Case--)
    24    {
    25          int hp1,hp2;
    26          int t1,t2;
    27          scanf("%d%d",&hp1,&hp2);
    28          if ( hp1 % 2 == 0)
    29           {
    30                 if (hp1 == 2)
    31                  t1 = 1;
    32                 else
    33                  t1 = 2;
    34        }
    35       else
    36        {
    37              if (IsPrime(hp1))
    38               t1 = 1;
    39              else
    40               {
    41                     if (IsPrime(hp1-2))
    42                      t1 = 2;
    43                     else
    44                      t1 = 3;
    45            }
    46        }
    47       
    48       
    49       if ( hp2 % 2 == 0)
    50           {
    51                 if (hp2 == 2)
    52                  t2 = 1;
    53                 else
    54                  t2 = 2;
    55        }
    56       else
    57        {
    58              if (IsPrime(hp2))
    59               t2 = 1;
    60              else
    61               {
    62                     if (IsPrime(hp2-2))
    63                      t2 = 2;
    64                     else
    65                      t2 = 3;
    66            }
    67        }
    68       if (t1 >= t2)
    69        printf("God Li
    ");
    70       else
    71        printf("Master Qiu
    ");
    72    }
    73   return 0;
    74 }
    No Pain , No Gain.
  • 相关阅读:
    sencha touch 入门系列 (四)sencha touch 新建项目目录结构解析
    sencha touch 入门系列 (三)sencha touch 项目创建
    sencha touch 入门系列 (二)sencha touch 开发准备
    sencha touch 入门系列 (一)sencha touch 简介
    Android Weak Handler:可以避免内存泄漏的Handler库
    Android 中的冷启动和热启动
    Android4.0以上版本比较靠谱的获取手机屏幕分辨率的方法
    Android studio 获取每次编译apk时的日期
    android瓦片地图技术研究
    Android中的各种访问权限Permission含义
  • 原文地址:https://www.cnblogs.com/Xiper/p/4455101.html
Copyright © 2020-2023  润新知