CF Game
2015-02-08 23:06
881 查看
A. Game
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Input
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
Output "First" if the first player wins and "Second" otherwise.
Sample test(s)
input
output
input
output
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player
can always win if he plays wisely.
贪心的思想,好坑
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Input
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
Output "First" if the first player wins and "Second" otherwise.
Sample test(s)
input
2 2 1 2
output
Second
input
2 1 1 1
output
First
Note
Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player
can always win if he plays wisely.
贪心的思想,好坑
#include<stdio.h> int main() { int n1,n2,k1,k2; while(scanf("%d%d%d%d",&n1,&n2,&k1,&k2)!=EOF){ if(n1>n2)printf("First\n"); else printf("Second\n"); } return 0; }
相关文章推荐
- cf E. Fox and Card Game
- cf 320# "Or" Game (位运算)
- 1550 [CF1000]Shell Game
- CF 842A - Kirill And The Game
- CF 256C Furlo and Rublo and Game【博弈论,SG函数】
- CF 277C Game(博弈)
- CF 397 C. Table Tennis Game 2
- CF 578B "Or" Game
- CF-63E - Sweets Game(记忆化搜索dp+状态压缩)
- CF 327 A Flipping Game
- 动态规划(Funny Game,cf 731E)
- CF-63E - Sweets Game(记忆化搜索dp+状态压缩)
- cf 768 E. Game of Stones(组合游戏)@
- CF 268C 24 Game
- cf 777A - A. Shell Game (水)
- CF 256C Furlo and Rublo and Game【博弈论,SG函数】
- CF - 409 - A. The Great Game(IQ)
- 【CF 534F】Game
- cf D. "Or" Game (前缀+后缀维护单点更新)
- CF 354B - Game with Strings(状压+博弈)