zoukankan      html  css  js  c++  java
  • BOJ 1577 Easy Game

    Easy Game

    Accept:7     Submit:7

    Time Limit:1000MS     Memory Limit:65536KB

    Description

    It's going to be a very easy game to all of you, and that's why the problem is placed at problem A.

    There are n coins on the desk. Alice and Bob are taking these coins alternately, and Alice starts first. The rules are easy: if the current number of coins n is an odd number, the player can only take one coin among them; otherwise, that if n is even, the player can take either one coin or half of them as he/she likes. The one who cannot make operations loses the game. Your task is to determine who will be the winner if both of them take the best strategy.

    Input Format

    The first line is the number of test cases T(1≤T≤1000).

    Each test case contains only one integer n(0≤n≤109), which denotes the number of coins on the desk initially.

    Output Format

    If Alice wins, output 'Alice', otherwise output 'Bob'.

    Sample Input

    1

    1

    Sample Output

    Alice

    新生排位赛第四场的A题,一道水题10分钟就过了,当时心中窃喜啊^_^

    这道题从1开始算几个小数据便可以发现规律:

    输入数据为1,3的Alice赢,输入数据为2的Bob赢,其他输入数据偶数的Alice赢,奇数的Bob赢。

    代码很容易写出……

     1 #include<iostream>
     2 
     3 using namespace std;
     4 
     5 int main()
     6 {
     7     long t;
     8 
     9     cin>>t;
    10 
    11     while(t--)
    12     {
    13         long n;
    14 
    15         cin>>n;
    16 
    17         if(n==1)
    18             cout<<"Alice"<<endl;
    19         else if(n==2)
    20             cout<<"Bob"<<endl;
    21         else if(n==3)
    22             cout<<"Alice"<<endl;
    23         else if(n%2==0)
    24             cout<<"Alice"<<endl;
    25         else
    26             cout<<"Bob"<<endl;
    27     }
    28 
    29     return 0;
    30 }
    [C++]
  • 相关阅读:
    [国家集训队]数颜色 / 维护队列
    【模板】二逼平衡树(线段树+平衡树)
    jenkins实现接口自动化持续集成(python+pytest+ Allure+git)
    Locust快速上手指南
    缓解多分类的样本不均衡问题
    PlayStation@4功能介绍及测试应用
    APP专项测试-弱网测试
    游戏自动化测试-局内战斗
    Windows下JMeter分布式压测环境搭建
    基于simhash的文本去重原理
  • 原文地址:https://www.cnblogs.com/lzj-0218/p/3187312.html
Copyright © 2011-2022 走看看