题目描述:
Two players play a simple game. Each player is provided with a box with balls. First player’s box contains exactly n1 balls and second player’s box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can’t make a move loses. Your task is to determine who wins if both players play optimally.
输入描述:
The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.
This problem doesn’t have subproblems. You will get 3 points for the correct submission.
输出描述:
Output “First” if the first player wins and “Second” otherwise.
输入:
2 2 1 2
2 1 1 1
输出:
Second
First
题意:
两个人有n1,n2个球,然后分别最多拿出 k1,k2个球,然后扔掉,谁先拿完谁输。
题解:
简单博弈,假设两人足够聪明,每次都只丢一个,那么,谁的球多,谁就能赢。如果一样,先手输
代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
int n,m,k1,k2;
while(scanf("%d%d%d%d",&n,&m,&k1,&k2)!=EOF){
if(n > m) printf("First\n");
else printf("Second\n");
}
return 0;
}