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++]
  • 相关阅读:
    用javafx webview 打造自己的浏览器
    用cef Python打造自己的浏览器
    无需人工智能和机器学习,实现基于手势识别的计算器
    经常抱怨在公司学不到技术,学的技术没有使用场景怎么破?
    Linux相关集合
    个人博客注册,申请,美化流程
    Django注意知识点(二)
    Django 注意知识点(一)
    Java学习笔记(四)
    Java学习笔记(三)
  • 原文地址:https://www.cnblogs.com/lzj-0218/p/3187312.html
Copyright © 2011-2022 走看看