题目描述

One day, Bessie decides to challenge Farmer John to a game of 'Cow Checkers'. The game is played on an M*N (1 <= M <= 1,000,000; 1 <= N <= 1,000,000) checkerboard that initially contains a single checker piece on the checkboard square coordinates (X, Y) (0 <= X < M; 0 <= Y < N). The bottom leftmost square of the checkerboard has

coordinates (0, 0), and the top rightmost square has coordinates (M-1, N-1). Bessie always moves first, and then the two players alternate turns. Each turn comprises one of three types of moves:

1) Move the checker piece to any square on the same row to the left of its current position.

2) Move the checker piece to any square on the same column below its current position.

3) Move the checker piece to any spot k squares below and k squares to the left of the current square (where k is any positive integer such that this new spot is still on the checkerboard).

The first player unable to make a move (i.e., because the checker is at (0, 0)) loses. Given that Bessie always goes first, determine who will win the game if both play optimally.

Play and report the winner for T games (1 <= T <= 1,000) reading in a new X,Y starting value for each new game.

有一天,Bessie准备玩一个叫做奶牛跳棋的游戏,来挑战Farmer John。

这个游戏的棋盘大小为 M*N (1 <= M <= 1,000,000; 1 <= N <= 1,000,000) 。最初棋盘上只有一个棋子在(x,y),棋盘的左下角坐标是(0,0),右上角的坐标是(M-1,N-1)。

每次游戏Bessie都是第一个开始,之后两个人轮流。

每次下棋的时候都有三种走法:

1.向左走任意步

2.向下走任意步

3.向左走k步然后向下走k步(k可随便取值,只要不走出棋盘)

先走到(0,0)的人就算输。

游戏共有T次,每次都会给出一个新的坐标(x,y),请输出每一轮赢家的名字。

输入输出格式

输入格式:

* Line 1: Two space-separated integers: M and N

* Line 2: A single integer: T

* Lines 3..T+2: Two space-separated integers: X and Y

第一行:M N

第二行:T

第三行到第T+2行:这一轮的X Y

输出格式:

* Lines 1..T: Should contain either 'Farmer John' or 'Bessie' depending on who wins each game.

共T行,每一行输出那一轮的赢家

思路;

这是一道标准的博弈论(不过好难想啊!!)

横坐标和纵坐标可以抽象为两堆石子

向下走任意步=拿出A堆任意个石子,向左走任意步=拿出B堆任意个石子

向左走和向下走相同的任意步=拿出A堆和B堆个数相等的任意个石子

这就抽象成了一个威佐夫博弈的模型

套用公式算一下是否是奇异局面就行(不知道什么是威佐夫博弈的请出门左转百度,讲的很详细)

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#define rii register int i
using namespace std;
int x,y,n,t,m;
int check(int l,int k)
{
if(l>k)
{
swap(l,k);
}
int wzf=(double)((k-l)*(sqrt()+)/);
if(wzf==l)
{
return ;
}
else
{
return ;
}
}
int main()
{
scanf("%d%d",&n,&m);
scanf("%d",&t);
for(rii=;i<=t;i++)
{
scanf("%d%d",&x,&y);
int pd=check(x,y);
if(pd==)
{
cout<<"Bessie"<<endl;
}
else
{
cout<<"Farmer John"<<endl;
}
}
}

[USACO11OPEN]奶牛跳棋Cow Checkers(博弈论)的更多相关文章

  1. LUOGU P3024 [USACO11OPEN]奶牛跳棋Cow Checkers

    题目描述 One day, Bessie decides to challenge Farmer John to a game of ‘Cow Checkers’. The game is playe ...

  2. 3298: [USACO 2011Open]cow checkers

    3298: [USACO 2011Open]cow checkers Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 65  Solved: 26[Su ...

  3. BZOJ3298: [USACO 2011Open]cow checkers(佐威夫博弈)

    3298: [USACO 2011Open]cow checkers Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 195  Solved: 96[S ...

  4. bzoj 3298: [USACO 2011Open]cow checkers -- 数学

    3298: [USACO 2011Open]cow checkers Time Limit: 10 Sec  Memory Limit: 128 MB Description 一天,Besssie准备 ...

  5. BZOJ3298[USACO 2011Open]cow checkers——威佐夫博弈

    题目描述 一天,Besssie准备和FJ挑战奶牛跳棋游戏.这个游戏上在一个M*N的棋盘上, 这个棋盘上在(x,y)(0<=x棋盘的左下角是(0,0)坐标,棋盘的右上角是坐标(M-1,N-1). ...

  6. 洛谷P1472 奶牛家谱 Cow Pedigrees

    P1472 奶牛家谱 Cow Pedigrees 102通过 193提交 题目提供者该用户不存在 标签USACO 难度普及+/提高 提交  讨论  题解 最新讨论 暂时没有讨论 题目描述 农民约翰准备 ...

  7. BZOJ3298: [USACO 2011Open]cow checkers 威佐夫博弈

    Description 一天,Besssie准备和FJ挑战奶牛跳棋游戏.这个游戏上在一个M*N的棋盘上, 这个棋盘上在(x,y)(0<=x棋盘的左下角是(0,0)坐标,棋盘的右上角是坐标(M-1 ...

  8. 【bzoj3298】[USACO 2011Open]cow checkers(博弈论)

    题目传送门:https://www.lydsy.com/JudgeOnline/problem.php?id=3298 博弈论经典结论题,我也没什么好说的.matrix67大佬比我想得深入的多:捡石子 ...

  9. 【dp】奶牛家谱 Cow Pedigrees

    令人窒息的奶牛题 题目描述 农民约翰准备购买一群新奶牛. 在这个新的奶牛群中, 每一个母亲奶牛都生两个小奶牛.这些奶牛间的关系可以用二叉树来表示.这些二叉树总共有N个节点(3 <= N < ...

随机推荐

  1. select支持多查询,获取分页count

    在我们使用mybatis 时,当我们根据分页去查询数据集时,需要传入的参数有page(页码)和size(每页的条数),而我们期望获取到的数据有,小于或等于size的list数据集,同时我们还需要得到一 ...

  2. 位运算(4)——Missing Number

    Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...

  3. mysql三-1:理解存储引擎

    一.什么是存储引擎 mysql中建立的库===>文件夹 库中建立的表===>文件 生活中我们用来存储数据的文件有不同的类型,每种文件类型对应各自不同的处理机制:比如处理文本用txt类型,处 ...

  4. cocoapods的安装和安装过程中遇到的问题

    查看当前的ruby版本,我的版本是ruby 2.0.0p648 小于2.2安装cocoapods时会遇到以下问题 $ ruby -v 查看当前ruby源,默认为 https://rubygems.or ...

  5. wxpython 创建工具栏和菜单栏

    下面看一下关于创建工具栏,状态栏和菜单的方法,看下面一个例子: import wx class ToolBarFrame(wx.Frame): def __init__(self,parent,id) ...

  6. php 四种基本排序算法

    冒泡排序 思路分析:法如其名,就是像冒泡一样,每次从数组当中 冒一个最大的数出来. 第一轮:从第一个到最后一个冒泡比较,运行结果:最后一个最大 第二轮:从第一个到倒数第二个冒泡比较, 运行结果:最后一 ...

  7. XP环境安装request包报错:离线安装packages: certifi urllib3 idna chardet

    分别下载 request certifi urllib3 idna chardet 安装包 数据包下载地址:https://pypi.org/ 解压到python安装目录 使用cmd命令进入..\py ...

  8. 关于GitHubGit

    一.Github项目地址:https://github.com/gyguyt/Helloworld123 二.什么是Github? Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或 ...

  9. hdu-2197 本原串---枚举因子+容斥定理

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2197 题目大意: 由0和1组成的串中,不能表示为由几个相同的较小的串连接成的串,称为本原串,有多少个 ...

  10. ACM-ICPC (10/20)

    B. Bakery time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...