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++]
  • 相关阅读:
    Python 正则表达式(分组)
    django 笔记
    Java代理和动态代理机制分析和应用
    Chrome浏览器如何调试移动端网页信息
    【数据分析】Excle中安装数据分析工具
    【BigData】Java基础_socket编程中使用多线程
    【BigData】Java基础_多线程
    【BigData】Java基础_socket编程
    财务报表之利润表
    资产负债表的会计恒等式
  • 原文地址:https://www.cnblogs.com/lzj-0218/p/3187312.html
Copyright © 2011-2022 走看看