Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1019    Accepted Submission(s): 373


Problem Description
Bo is a "Life Winner".He likes playing chessboard games with his girlfriend G.

The size of the chessboard is 
 

 

Input
In the first line,there is a number 4
 

 

Output
For each question,print the answer.
 

 

Sample Input
4 1 5 5 2 5 5 3 5 5 4 5 5
 

 

Sample Output
G G D B

 

/* ***********************************************
Author        :guanjun
Created Time  :2016/7/27 13:04:59
File Name     :hdu5754.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 100010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
const double Gsr=(1+sqrt(5.))/2.; 
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 a,n,m;
 
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    #endif
    //freopen("out.txt","w",stdout);
    int t;
    cin>>t;
    while(t--){
        cin>>a>>n>>m;
        if(a==1){
            if((n&1)&&(m&1))puts("G");
            else puts("B");
        }
        if(a==2){
            if(n==m){//后手赢
                puts("G");
            }
            else{
                puts("B");
            }
        }
        if(a==3){
            if(n<m)swap(n,m);
            if((n==m)&&(n%3==1))puts("G");
            else if((n%3==0)&&(m==n-1))puts("B");
            else puts("D");
        }
        if(a==4){//威佐夫博弈
            n--,m--;
            if(n>m)swap(n,m);
            if(n==(int)(Gsr*(m-n))){
                puts("G");
            }
            else puts("B");
        }
    }
    return 0;
}

找规律。皇后的时候转换成博弈

“有两堆石子,每次可以在一堆里取任意(非空)颗(相当于是车的走法),或者在两堆里取相同(非空)颗(相当于是象的走法),取到最后一颗石子的人获胜,问先后手谁有必胜策略。”

 

相关文章: