bzoj3298[USACO 2011Open]cow checkers

Posted quzhizhou

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了bzoj3298[USACO 2011Open]cow checkers相关的知识,希望对你有一定的参考价值。

  题目传送门:https://www.lydsy.com/JudgeOnline/problem.php?id=3298

  博弈论经典结论题,我也没什么好说的。matrix67大佬比我想得深入的多:捡石子游戏、 Wythoff 数表和一切的 Fibonacci 数列

  代码:

技术分享图片
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<string>
#include<iostream> 
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define ull unsigned long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define eps 1e-18
#define maxn 2000010
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<0||9<c;c=getchar())if(c==-)f=-1; for(;0<=c&&c<=9;c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-0; return tmp*f;}
inline ll power(ll a,ll b){ll ans=1; for(;b;b>>=1){if(b&1)ans=ans*a%mod; a=a*a%mod;} return ans;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void swap(int &a,int &b){int tmp=a; a=b; b=tmp;}
using namespace std;
int vis[maxn];
int a[maxn];
int n,m;
int main()
{
    n=read(); m=read();
    int now=1;
    for(int i=1;;i++){
        while(vis[now])++now;
        if(now>n||now>m)break;
        vis[now]=1; vis[now+i]=1;
        a[now+i]=now; a[now]=now+i;
    }
    int t=read();
    while(t--){
        int n=read(),m=read();
        if(a[n]==m)printf("Farmer John
");
        else printf("Bessie
");
    }
}
bzoj3298

 

以上是关于bzoj3298[USACO 2011Open]cow checkers的主要内容,如果未能解决你的问题,请参考以下文章

bzoj 3299 [USACO2011 Open]Corn Maze玉米迷宫(最短路)

[BZOJ2442][Usaco2011 Open]修剪草坪

BZOJ-3296: [USACO2011 Open] Learning Languages (并查集)

bzoj3297[USACO2011 Open]forgot(dp + string)

bzoj2442[Usaco2011 Open]修剪草坪*

[BZOJ2442][Usaco2011 Open]修剪草坪 dp+单调队列优化