1349: Taking Pebbles

Submit Page    Summary    Time Limit: 1 Sec     Memory Limit: 128 Mb     Submitted: 233     Solved: 141


Description

There is a pile of N pebbles initially. Alice and Bob are playing a taking pebbles game as follows:
    Alice and Bob moves by turns, Alice moves first. For each move, the player can takes away at least one and at most half of the pebbles remained (“at most half” means you can take way at most k (k >= 1) pebbles if there are 2*k or 2*k+1 pebbles remained). If there is only one pebble remained, the player can also take away this pebble. The player who takes away the last pebble wins.
    If Alice and Bob are both clever enough, and they both want to be the winner, who will win?

Input

The first line has one integer T (1 <= T <= 200), means there are T test cases.
    For each test case, there is only one line with an integer N (2 <= N <= 109), means the number of pebbles initially.

Output

For each test case, print “Alice” (without quotation marks) in one line if Alice will win. Otherwise print “Bob” (without quotation marks) instead.

Sample Input

5
2
3
4
5
6

Sample Output

Bob
Alice
Alice
Bob
Alice

Hint

Source

中南大学第一届长沙地区程序设计邀请赛

 
碰到这种题就有点郁闷,因为写的很少
一般都是打个表,找找看有没有规律
因为答案就两种情况
肯定是跟n有关
那可能是有规律的......
试着打个表
果然!!!!!
n为以下数字的时候
2
5
11
23
47
95
191
383
767
Bob赢
找到这个规律之后
还pe,re了好几发
因为还想着把表存下来....
真是傻得一批
直接判断一下不是不是这些数字就可以了啊
.....
打表函数:
void dabiao()
{
f[]=;
f[]=;
for(int i=; i<=; i++)
{
int flag=;
int x=i/;
if(i%)
x=i/+;
for(int j=i-; j>=x; j--)
{
if(f[j]==)
{
flag=;
break;
}
}
if(flag==)
{
f[i]=;
}
} for(int i=; i<=; i++)
{
if(f[i]==)
{
printf("%d\n",i);
}
}
}

code:

#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<memory.h>
#include<memory>
using namespace std;
#define max_v 1005
#define max_n 1000
typedef long long LL;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
if(n%==&&n!=)
printf("Alice\n");
else if(n==)
printf("Bob\n");
else
{
int k=;
while(k<n)
{
k=k*+;
}
if(k==n)
printf("Bob\n");
else
printf("Alice\n");
}
}
return ;
}
/*
碰到这种题就有点郁闷,因为写的很少
一般都是打个表,找找看有没有规律
因为答案就两种情况
肯定是跟n有关
那可能是有规律的......
试着打个表
果然!!!!!
n为以下数字的时候
2
5
11
23
47
95
191
383
767
Bob赢
找到这个规律之后
还pe,re了好几发
因为还想着把表存下来....
真是傻得一批
直接判断一下不是不是这些数字就可以了啊
..... */
/*
2
5
11
23
47
95
191
383
767
*/

1349: Taking Pebbles (博弈 打表找规律)的更多相关文章

  1. hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)

    Nim or not Nim? Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  2. HDU 5795 A Simple Nim (博弈 打表找规律)

    A Simple Nim 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5795 Description Two players take turns ...

  3. vijos 1004 伊甸园日历游戏 博弈+打表找规律

    描述 Adam和Eve玩一个游戏,他们先从1900.1.1到2001.11.4这个日期之间随意抽取一个日期出来.然后他们轮流对这个日期进行操作: 1 : 把日期的天数加1,例如1900.1.1变到19 ...

  4. HDU2149-Good Luck in CET-4 Everybody!(博弈,打表找规律)

    Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  5. hdu_5795_A Simple Nim(打表找规律的博弈)

    题目链接:hdu_5795_A Simple Nim 题意: 有N堆石子,你可以取每堆的1-m个,也可以将这堆石子分成3堆,问你先手输还是赢 题解: 打表找规律可得: sg[0]=0 当x=8k+7时 ...

  6. HDU 4861 Couple doubi (数论 or 打表找规律)

    Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a ...

  7. HDU 3032 multi-sg 打表找规律

    普通NIM规则加上一条可以分解为两堆,标准的Multi-SG游戏 一般Multi-SG就是根据拓扑图计算SG函数,这题打表后还能发现规律 sg(1)=1 sg(2)=2 sg(3)=mex{0,1,2 ...

  8. HDU 5753 Permutation Bo (推导 or 打表找规律)

    Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

  9. HDU-4664 Triangulation 博弈,SG函数找规律

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4664 题意:一个平面上有n个点(一个凸多边形的顶点),每次可以连接一个平面上的两个点(不能和已经连接的 ...

随机推荐

  1. JavaScript正则表达式检验手机号码、邮箱、ip地址等

    1)检测IP地址的正则表达式 ((2 [0-4] \d | 25[0-5] | [01]?\d\d?) \.){3}(2 [0-4] \d | 25[0-5] | [01]?\d\d?) 2 [0-4 ...

  2. Django基础三之视图函数

    一 Django的视图函数view 一个视图函数(类),简称视图,是一个简单的Python 函数(类),它接受Web请求并且返回Web响应. 响应可以是一张网页的HTML内容,一个重定向,一个404错 ...

  3. Oracle数据库函数总结

    1.ceil()向上取整,结果为124.select ceil(123.123) from dual;2.floor()向下取整,结果为123.select floor(123.123) from d ...

  4. Web 开发者学习路线图

      2017 Web 开发者学习路线图(头图源自谷歌) 本文是源自 Github 上 Kamran Ahmed 建立的一个仓库.在文中,作者为他的老教授分享了一组成为前端与后端开发者以及 Devops ...

  5. 润乾V4的最小化部署方式

     在接触到的很多项目实际应用中,部署润乾V4都是使用润乾V4设计器自带的WEB发布向导,直接生成webRoot目录,然后将该目录下的所有文件COPY到项目目录下,然后修改web.xml文件和rep ...

  6. Android ListView几个重要属性

    1.transciptMode属性,需要用ListView或者其它显示大量Items的控件实时跟踪或者查看信息,并且希望最新的条目可以自动滚动到可视范围内.通过设置的控件transcriptMode属 ...

  7. alter system register的用法

    转自 http://blog.csdn.net/njyxfw/article/details/7516143 今天一个同事问到我,有没动态注册监听的命令,查了下,找到了alter system reg ...

  8. redis介绍(1)命令介绍

    redis 的五大基本类型的简单命令 对key--value中的value的一些简单命令 keys * 查询redis中的所有key exists key 查询key是否存在 flushdb 清空当前 ...

  9. Python DDT(data driven tests)模块心得

    关于ddt模块的一些心得,主要是看官网的例子,加上一点自己的理解,官网地址:http://ddt.readthedocs.io/en/latest/example.html ddt(data driv ...

  10. Singleton单例模式--C++实现

    1. 只支持单线程 (不推荐) #include <iostream> using namespace std; class Singleton { public: static Sing ...