现在的位置: 首页 > 综合 > 正文

UVA 12293 – Box Game (博弈)

2013年10月16日 ⁄ 综合 ⁄ 共 800字 ⁄ 字号 评论关闭

题目地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=478&problem=3714&mosmsg=Submission+received+with+ID+12237111

题意:给你两个箱子,一个箱子里面有n个球,另外一个箱子只有一个球,两个人轮流操作,每次将最少箱子里面的球拿走,然后再将另外的一个箱子的球重新分配给这两个箱子,知道不能再操作为止(也就是1  ,1),给你一个n,问谁赢。

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
#include <ctime>
using namespace std;

typedef long long LL;
const int N=100005;
const double eps=1e-6;
const int M=1<<12;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const int mod=1000000007;

int main()
{
    int i,n;
    while(scanf("%d",&n)&&n)
    {
        if(((n+1)&n)==0)
            puts("Bob");
        else
            puts("Alice");
    }
    return 0;
}

抱歉!评论已关闭.