Game



Time Limit: 1sec    Memory Limit:256MB
Description

     As we know, Alice is a lovely little girl in primary school, she has a childhood  sweetheart Bob, they often 

playing game together.Now, they are playing a game with coins.

    A row of N coins on the desk from left to right.The side of some coins are  head(正面),others are tail(反面).Alice 
and Bob play in turn, every time the player can only choose a coin with head side and reverse it to tail, at the mean
 time ,all the coins that from the left side of the chosen one will also be reversed,head will change to tail ,and tail change to head.
    The player who cannot choose an head coin lost the game.Suppose that both Alice and Bob do their best in the game and Alice always play first.You are to write a program to determine who will finally win the game. 
Input

    The Input contain T(1 <= T <= 10) test cases. For each test case, the first line is an integer N(1 <= N <= 100),

then N coins in the next line,1 means head and 0 means tail.


Output

    For each test cases, output the name of winner in a line.


Sample Input

2
2 
0 1
5
1 0 0 1 0
Sample Output
Bob
Alice

题目来自移动信息工程学院短码之美月赛02

题目大意是给出01序列代表硬币正反面,1为正,每个人只能选择一个1变为0,同时让这个1左边的所有0变成1,所有1变成0,Alice先开始,输出赢家。这道题通过找规律不难发现最后的1右边的0是没用的,并且当第一个硬币为正时,Alice无论怎么翻都能把状态变成000...111...这样的序列,意味着Bob必须会输。

// Problem#: 14506
// Submission#: 3719425
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <bits/stdc++.h>
using namespace std;
int num[102];
int main(){
    int n;
    cin >> n;
    while(n--){
        int number;
        cin>>number;
        for(int i=0;i<number;i++){
            cin>>num[i];
        }
        if(num[0]){
            cout<<"Alice"<<endl;
        }
        else{
            cout<<"Bob"<<endl;
        }
    }
}                                 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值