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++]
  • 相关阅读:
    mysql中中文乱码问题
    jdbc操作数据库
    PreparedStatement解决sql注入问题
    向mysql数据库中插入大二进制文件和大文本
    Statement及PreparedStatement执行多个sql
    自定义EL函数
    自定义标签
    dom4j操作xml对象
    mysql中中文乱码问题
    jdbc操作数据库
  • 原文地址:https://www.cnblogs.com/lzj-0218/p/3187312.html
Copyright © 2011-2022 走看看