zoukankan      html  css  js  c++  java
  • Game

    Game

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 50 Accepted Submission(s): 44
     
    Problem Description
    Bob and Alice are playing a new game. There are n boxes which have been numbered from 1 to n. Each box is either empty or contains several cards. Bob and Alice move the cards in turn. In each turn the corresponding player should choose a non-empty box A and choose another box B that B<A && (A+B)%2=1 && (A+B)%3=0. Then, take an arbitrary number (but not zero) of cards from box A to box B. The last one who can do a legal move wins. Alice is the first player. Please predict who will win the game.
     
    Input
    The first line contains an integer T (T<=100) indicating the number of test cases. The first line of each test case contains an integer n (1<=n<=10000). The second line has n integers which will not be bigger than 100. The i-th integer indicates the number of cards in the i-th box.
     
    Output
    For each test case, print the case number and the winner's name in a single line. Follow the format of the sample output.
     
    Sample Input
    2
    2
    1 2
    7
    1 3 3 2 2 1 2
     
    Sample Output
    Case 1: Alice
    Case 2: Bob
     
    Author
    hanshuai@whu
     
    Source
    The 5th Guangting Cup Central China Invitational Programming Contest
     
    Recommend
    notonlysuccess
     
    /*
    题意:1到n的盒子里,是空的或者装着卡片,每人轮流移动卡片,Alice先手,移动卡片的规则:每次选择一个A,然后选择一个B
        要求 B<A&&(A+B)%2==1&&(A+B)%3==0,从A中抽取任意一张卡片放到B中,谁不能移动了,就输了。
    
    初步思路:这个就是先将能移动的盒子对找出来,然后统计能移动的牌
    
    #错误:上面的想法不完善,只是一方面的认为卡片会从一上一级向下一级移动。
    
    #补充:阶梯博弈,实际上卡片是在3的余数上进行转移的。
    
    #感悟:手残用了数组,开小了,wa了两发才发现
    */
    #include<bits/stdc++.h>
    using namespace std;
    int n;
    int x;
    int res=0;
    int t;
    void init(){
        res=0;
    }
    int main(){
        // freopen("in.txt","r",stdin);
        scanf("%d",&t);
        for(int ca=1;ca<=t;ca++){
            init();
            scanf("%d",&n);
            for(int i=1;i<=n;i++){
                scanf("%d",&x);
                if(i%6==0||i%6==2||i%6==5)
                    res^=x;
            }
            if(res) printf("Case %d: Alice
    ",ca);
            else printf("Case %d: Bob
    ",ca);
        }
        return 0;
    }
  • 相关阅读:
    CF1313A Fast Food Restaurant
    模板: zkw线段树
    从5个经典工作开始看语义SLAM
    LeetCode题号[200,299]刷题总结
    2020春招实习总结
    LeetCode题号[100,199]刷题总结
    LeetCode题号[1,99]刷题总结
    HashMap源码详解
    动态规划——楼层扔鸡蛋问题
    图论——迪杰斯特拉算法和最小生成树
  • 原文地址:https://www.cnblogs.com/wuwangchuxin0924/p/6404142.html
Copyright © 2011-2022 走看看