Life Winner Bo
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 3009 Accepted Submission(s): 1093
Problem Description
Bo is a "Life Winner".He likes playing chessboard games with his girlfriend G.
The size of the chessboard is N×M.The top left corner is numbered(1,1) and the lower right corner is numberd (N,M).
For each game,Bo and G take turns moving a chesspiece(Bo first).At first,the chesspiece is located at (1,1).And the winner is the person who first moves the chesspiece to (N,M).At one point,if the chess can't be moved and it isn't located at (N,M),they end in a draw.
In general,the chesspiece can only be moved right or down.Formally,suppose it is located at (x,y),it can be moved to the next point (x′,y′) only if x′≥x and y′≥y.Also it can't be moved to the outside of chessboard.
Besides,There are four kinds of chess(They have movement rules respectively).
1.king.
2.rook(castle).
3.knight.
4.queen.
(The movement rule is as same as the chess.)
For each type of chess,you should find out that who will win the game if they both play in an optimal strategy.
Print the winner's name("B" or "G") or "D" if nobody wins the game.
The size of the chessboard is N×M.The top left corner is numbered(1,1) and the lower right corner is numberd (N,M).
For each game,Bo and G take turns moving a chesspiece(Bo first).At first,the chesspiece is located at (1,1).And the winner is the person who first moves the chesspiece to (N,M).At one point,if the chess can't be moved and it isn't located at (N,M),they end in a draw.
In general,the chesspiece can only be moved right or down.Formally,suppose it is located at (x,y),it can be moved to the next point (x′,y′) only if x′≥x and y′≥y.Also it can't be moved to the outside of chessboard.
Besides,There are four kinds of chess(They have movement rules respectively).
1.king.
2.rook(castle).
3.knight.
4.queen.
(The movement rule is as same as the chess.)
For each type of chess,you should find out that who will win the game if they both play in an optimal strategy.
Print the winner's name("B" or "G") or "D" if nobody wins the game.
Input
In the first line,there is a number T as
a case number.
In the next T lines,there are three numbers type,N and M.
"type" means the kind of the chess.
T≤1000,2≤N,M≤1000,1≤type≤4
In the next T lines,there are three numbers type,N and M.
"type" means the kind of the chess.
T≤1000,2≤N,M≤1000,1≤type≤4
Output
For each question,print the answer.
Sample Input
41 5 52 5 53 5 54 5 5
Sample Output
GGDB
根据棋子的不同一共有四种博弈
前三种的np图



#include <iostream>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include<algorithm>
#define ans (sqrt(5)+1)/2
using namespace std;
int main(int argc, char *argv[])
{
int t;
scanf("%d",&t);
while(t--)
{
int s,m,n;
scanf("%d %d %d",&s,&n,&m);
if(s==1)
{
if(n%2==0||m%2==0)
{
printf("B\n");
}
else
{
printf("G\n");
}
}
if(s==2)
{
if(n==m)
printf("G\n");
else
printf("B\n");
}
if(s==3)
{
n--;
m--;
if(n>m)
{
swap(n,m);
}
if(n==m&&n%3==0)
{
printf("G\n");
}
else if(m%3==2&&m-n==1)
{
printf("B\n");
}
else
{
printf("D\n");
}
}
if(s==4)
{
m--;
n--;
if(n<m)
{
int temp=n;n=m;m=temp;
}
int k=(n-m);
n=(int)(((sqrt(5)+1)/2.0)*k);
if(m==n)
{
printf("G\n");
}
else
{
printf("B\n");
}
}
}
return 0;
}

本文介绍了一种基于不同棋子类型的棋盘游戏博弈策略,包括国王、车、马和皇后四种棋子。每种棋子都有其独特的移动规则,文章探讨了在两人轮流移动棋子的情况下,如何通过最优策略决定游戏的胜负。
760

被折叠的 条评论
为什么被折叠?



