Allice先拿,最后拿球的输。

Bob先拿,最后拿球的赢。

考虑Alice先拿球,当n=1时 Alice输  记dp[1]=0;

n=2,  dp[2]=1

n=3,  dp[3]=1

因为n=1,2的时候先手是A,所以A可以通过选一个还是两个球使得B在n=2,3时输。

n=4,  dp[4]=0

因为n=2,3时B可能是先手,所以B可以通过选一个还是两个球使得A在n=4的时候输。

n=5,dp[5]=1;

n=6,dp[6]=1;

因为n=4,5的时候先手是A,所以A可以通过选一个还是两个球使得B在n=5,6时输。

.......

dp[4]=dp[1]所以就可以看到规律了。。

同理 Bob也用类似的想法。

/* ***********************************************
Author :guanjun
Created Time :2016/6/24 22:49:21
File Name :1020.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int T,n;
cin>>T;
string s1,s2;
for(int t=;t<=T;t++){
cin>>n>>s1;
printf("Case %d: ",t);
if(s1=="Alice"){
if(n%==)puts("Bob");
else puts("Alice");
}
else{
if(n%==)puts("Alice");
else puts("Bob");
}
}
return ;
}

Lightoj 1020 - A Childhood Game的更多相关文章

  1. Lightoj 1020 - A Childhood Game (博弈)

    题目链接: 1020 - A Childhood Game 题目描述: Alice和Bob在玩弹珠游戏,两人轮流拿走弹珠,每次只能拿走一个或者两个,当Alice作为先手时谁拿走最后一个就是输家,而Bo ...

  2. lightoj 1020 (博弈水题)

    lightoj 1020 A Childhood Game 链接:http://lightoj.com/volume_showproblem.php?problem=1020 题意:一堆石子有 m 个 ...

  3. lightoj 1020 (博弈)

    思路:很简单的博弈,找出每个人先拿的必胜态进行状态转移即可. #include<cstdio> #include<string> #include<cstring> ...

  4. lightoj刷题日记

    提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...

  5. 区间DP LightOJ 1422 Halloween Costumes

    http://lightoj.com/volume_showproblem.php?problem=1422 做的第一道区间DP的题目,试水. 参考解题报告: http://www.cnblogs.c ...

  6. LightOj 1298 - One Theorem, One Year(DP + 欧拉)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1298 题意:给你两个数 n, p,表示一个数是由前 k 个素数组成的,共有 n 个素数 ...

  7. 1214 - Large Division -- LightOj(大数取余)

    http://lightoj.com/volume_showproblem.php?problem=1214 这就是一道简单的大数取余. 还想还用到了同余定理: 所谓的同余,顾名思义,就是许多的数被一 ...

  8. LightOJ Beginners Problems 部分题解

    相关代码请戳 https://coding.net/u/tiny656/p/LightOJ/git 1006 Hex-a-bonacci. 用数组模拟记录结果,注意取模 1008 Fibsieve's ...

  9. LightOJ 1341 唯一分解定理

    Aladdin and the Flying Carpet Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%lld &a ...

随机推荐

  1. 【HIHOCODER 1526】 序列的值(二进制DP)

    时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个长度为 n 的序列 a[1..n],定义函数 f(b[1..m]) 的值为在 [0,m-1] 内满足如下条件的 i ...

  2. 基本Sql语句汇总

    关于Sql语句的学习,选择的DBMS为SQL Server,Sql语句随着工作中的应用不断补充,不具备系统性,为个人笔记汇总,网上有很多优秀的资源,故不对每一处应用做过多细致的说明,后期会对部分篇幅较 ...

  3. MongoDB中WiredTiger的数据可用性设置

    此文已由作者温正湖授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. MongoDB中WiredTiger的参数配置主要通过 wiredtiger_open (http://so ...

  4. kissy学习

    http://docs.kissyui.com/1.4/docs/html/guideline/kmd.html

  5. 大数据学习——linux常用命令(三)

    三 文件操作 1创建文件 touch somefile.txt 创建一个空文件somefile.txt > 重定向操作符 echo "woshiwoa"> some.t ...

  6. https://www.cnblogs.com/freeflying/p/9950374.html

    https://www.cnblogs.com/freeflying/p/9950374.html

  7. 学渣乱搞系列之扩展KMP的那点事

    扩展KMP牵涉了一些相对运动的姿势,比较费解!本学渣看了一天的扩展KMP,打算写点东西...本文看后,出现的后果本人一概不负责.毕竟我不是很会表达. 扩展KMP是搞什么灰机的?本学渣所知道的扩展KMP ...

  8. noj 2033 一页书的书 [ dp + 组合数 ]

    传送门 一页书的书 时间限制(普通/Java) : 1000 MS/ 3000 MS          运行内存限制 : 65536 KByte总提交 : 53            测试通过 : 1 ...

  9. PAT (Advanced Level) 1034. Head of a Gang (30)

    简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...

  10. [Bzoj4722]由乃(线段树好题)(倍增处理模数小快速幂)

    4722: 由乃 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 360  Solved: 131[Submit][Status][Discuss] D ...