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. [移动端WEB] 移动端input标签按钮为什么在苹果手机上还有一层白色?

    移动端input标签按钮为什么在苹果手机上还有一层白色? 解决办法:其实蛮简单的,就加一个属性就好了 input { outline:0px ; -webkit-appearance: none; } ...

  2. 【小程序】返回顶部wx.pageScrollTo和scroll-view的对比

    一.wx.pageScrollTo(https://mp.weixin.qq.com/debug/wxadoc/dev/api/scroll.html) 1. 小程序中双击顶部的textbar.会默认 ...

  3. WPF 手机验证码 发送按钮倒计时 代码

    private async void SendButton_Click(object sender, RoutedEventArgs e) { var button = sender as Butto ...

  4. jsp到java后台中文乱码问题

    ---首先描述一下我的情况,我的jsp    设置了编码格式 <%@ page language="java" contentType="text/html; ch ...

  5. bootstrap作为mixin库的应用模式

    Bootstrap作为一个非常流行的前端css框架,得到了非常多的应用.一般的使用方法都是直接download bootstrap.css,作为css文件引入到html的markup中,随后直接引用其 ...

  6. [IIS] 配置PHP的过程与坑

    * 32位与64位程序的兼容性问题 如果64位的IIS内的处理程序需要使用32位程序或者扩展,必须在ApplicationPool里面的高级设置里,将AppPool设置为允许32位.否则32位的程序将 ...

  7. Sql Server中的谓词和运算符

    谓词和运算符配合使用是我们得到理想数据的最佳途径. 一.浅谈谓词 谓词的概念:一个运算结果为True.False或Unknown的逻辑表达式.它的运用范围有:where子句.Having子句.Chec ...

  8. SqlServer查询存储过程中包含指定的内容

    存储过程太多,有时只记得存储过程里面的某一点类容,想要找到对应的存储过程: SELECT obj.Name 存储过程名, sc.TEXT 存储过程内容 FROM syscomments sc INNE ...

  9. ASP.NET MVC实现通用设置

    网站中的设置实现方式有好几种,其中有将设置类序列化然后保存到文件中(例如使用XML序列化然后以XML形式保存在文件中),或者将设置信息保存到数据库中. 保存到数据库中的方式就是将设置的项作为key,设 ...

  10. Oracle GoldenGate OGG管理员手册(较早资料)

    第一章 系统实现简述 前言 编写本手册的目的是为系统管理员以及相关操作人员提供 Oracle  Goldengat  软 件的日常维护和使用的技术参考: 3 ORACLE 第二章 OGG 日常维护操作 ...