bzoj3298 [USACO 2011Open]cow checkers

来源:互联网 发布:怎样设置网站主域名 编辑:程序博客网 时间:2024/06/08 03:09

题目

先找规律,O(n)可过,但是,我们要更优。

某玄学模拟赛

威佐夫博弈。。

#include<bits/stdc++.h>#define N 10000000using namespace std;int tmp;int T,x,y,m,n;int main(){//  freopen("chess.in","r",stdin);//  freopen("chess.out","w",stdout);    cin>>m>>n;    cin>>T;    while(T--)    {        cin>>x>>y;        if(x>y)swap(x,y);        int tmp=floor((1.0+sqrt(5.0))/2.0*(double)(y-x));        if(tmp==x)puts("Farmer John");        else puts("Bessie");    }    return 0;}