题意: 一个无限大的棋盘,一开始在1,1,有三种移动方式,(x+1,y)(x,y+1) (x+k,y+k)最后走到nm不能走了的人算输。。

析:。我们看成一开始在(n,m),往1,1,走,所以自然可以从1,1,开始递推往出,那么打表程序就出来了。。

打出表以后我们观察到k等于1时稍有特殊,其他则与  (min(cx,cy)&1)^((n+m)&1)) 有关ps(其中cx=n/(k+1),cy=m/(k+1))

那么就愉快的分类讨论外加试一试和表对照一下就好了。。

代码如下:

#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
using namespace std ;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 2000 + 5;
const int dr[] = {0, 0, -1, 1};
const int dc[] = {-1, 1, 0, 0};
//int n, m;
int n,m,k,q; void print(int x){
cout << (x == 1 ? "Alice" : "Bob") << endl;
} int main(){
int t;
cin >> t;
while(t--){
cin >> q >> k;
while(q--){
cin >> n >> m;
int cx = n/(k+1), cy = m / (k+1);
int yx = n % (k+1), yy = m % (k+1);
if(k == 1){
if((yx == 0 && m >= n) || (yy == 0 && n >= m)) print(1);
else print((0^((n+m)&1)));
}
else{
if((yx == 0 && m >= n) || (yy == 0 && n >= m)) print(1);
else print((0^(min(cx,cy)&1)^((n+m)&1)));
}
}
}
return 0;
}

HDU 5708 Alice and Bob (博弈,找规律)的更多相关文章

  1. HDU 1079 Calendar Game(博弈找规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1079 题目大意:给你一个日期(包含年月日),这里我表示成year,month,day,两人轮流操作,每 ...

  2. HDU 4111 Alice and Bob (博弈+记忆化搜索)

    题意:给定 n 堆石头,然后有两种操作,一种是把从任意一堆拿走一个,另一种是把一个石子放到另一堆上. 析:整体看,这个题真是不好做,dp[a][b] 表示有 a 堆1个石子,b个操作,操作是指把其他的 ...

  3. HDU 4388 Stone Game II {博弈||找规律}

    Stone Game II Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  4. hdu 2865 Polya计数+(矩阵 or 找规律 求C)

    Birthday Toy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  5. 题解报告:hdu 1564 Play a game(找规律博弈)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1564 Problem Description New Year is Coming! ailyanlu ...

  6. HDU 3032 (SG打表找规律)

    题意: 有n堆石子,alice先取,每次可以选择拿走一堆石子中的1~x(该堆石子总数) ,也可以选择将这堆石子分成任意的两堆.alice与bob轮流取,取走最后一个石子的人胜利. 思路: 因为数的范围 ...

  7. hdu 4268 Alice and Bob(multiset|段树)

    Alice and Bob Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  8. 51nod_1831: 小C的游戏(Bash博弈 找规律)

    题目链接 此类博弈不需要考虑sg函数,只需要确定必胜态和必败态,解题思路一般为打败先打表找规律,而后找规律给出统一的公式.打表方式:给定初始条件(此题中为ok[0]=ok[1]=0),然后从低到高枚举 ...

  9. hdu 4111 Alice and Bob 记忆化搜索 博弈论

    Alice and Bob Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pi ...

随机推荐

  1. 20160206.CCPP体系详解(0016天)

    代码片段(01):.指针.c+02.间接赋值.c 内容概要:内存 ///01.指针 #include <stdio.h> #include <stdlib.h> //01.取地 ...

  2. Asp.net动态调用WebService

    Public Class WebServiceHelper #Region "InvokeWebService" '动态调用web服务 Public Shared Function ...

  3. 搭建 MPICH3 并行计算环境

    先记录在单机MacBook上的搭建,实验室集群的搭建流程是一样的,不过每台机器都需要做一次. MacBook: 1.安装mpich3: $ ./configure --prefix=/Users/xi ...

  4. 聊聊Oracle 11g的Snapshot Standby Database(上)

    Oracle 11g是Data Guard的重要里程碑版本.在11g中,Active DataGuard.Advanced Compression等特性大大丰富了Data Guard的功能和在实践领域 ...

  5. “-bash: svn: command not found”

    今天升级了Xcode5.界面更加的清爽了,但是在命令行里SVN也失去了作用了. 当我要更新的时候提示:“-bash: svn: command not found” 解决办法: 1:打开Prefere ...

  6. C# 保留2位小数

    1.只要求保留N位不四舍5入 float   f   =   0.55555f;                 int   i   =(int)(f   *   100);             ...

  7. 【LeetCode】111 - Minimum Depth of Binary Tree

    Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...

  8. Mysql报错:1172 - Result consisted of more than one row

    执行mysql函数时报错:1172 - Result consisted of more than one row 函数语句中select into语句中WHERE account = userNam ...

  9. MATLAB将矩阵使用.txt文件格式保存

    具体的命令是:用save *.txt -ascii x x为变量 *.txt为文件名,该文件存储于当前工作目录下,再打开就可以 打开后,数据有可能是以指数形式保存的.   看下面这个例子: a =[1 ...

  10. PHP上传大文件和处理大数据

    1. 上传大文件 /* 以1.5M/秒的速度写入文件,防止一次过写入文件过大导致服务器出错(chy/20150327) */ $is_large_file = false; if( strlen($x ...