zoukankan      html  css  js  c++  java
  • Gym

    G. The jar of divisors

     

    Alice and Bob play the following game. They choose a number N to play with. The rules are as follows:

    - They write each number from 1 to N on a paper and put all these papers in a jar.

    - Alice plays first, and the two players alternate.

    - In his/her turn, a player can select any available number M and remove its divisors including M.

    - The person who cannot make a move in his/her turn wins the game.

    Assuming both players play optimally, you are asked the following question: who wins the game?

    Input

    The first line contains the number of test cases T (1  ≤  T  ≤  20). Each of the next T lines contains an integer (1  ≤  N  ≤ 1,000,000,000).

    Output

    Output T lines, one for each test case, containing Alice if Alice wins the game, or Bob otherwise.

    Examples
    input
    2
    5
    1
    output
    Alice
    Bob

    博弈论题目。1就是Bob赢否则就是Alice赢,不知道怎么来的,算了8个发现只有1是Bob赢就这样写了,没想到还真过了。

     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <string.h>
     4 #include <algorithm>
     5 #define ll long long
     6 using namespace std;
     7 int main(){
     8     int t,n;
     9     cin>>t;
    10     while(t--){
    11         cin>>n;
    12         if(n == 1){
    13             cout << "Bob
    ";
    14         }else cout << "Alice
    ";
    15     }
    16     return 0;
    17 }
    
    
  • 相关阅读:
    PHP如何让apache支持.htaccess 解决Internal Server Error The server …错误
    PHP文件的上传下载
    Centos rsync文件同步配置
    Nginx负载均衡策略
    MongoDB 基本命令
    nginx keepalived 主从切换
    iptabels 的一些配置
    负载均衡 LVS+Keepalived
    FreeBSD 系统的配置.
    linux下利用curl监控web应用状态
  • 原文地址:https://www.cnblogs.com/xingkongyihao/p/7197312.html
Copyright © 2011-2022 走看看