codeforces Rockethon 2015 - A. Game (= =)
来源:互联网 发布:女士牛仔裤品牌 知乎 编辑:程序博客网 时间:2024/05/02 02:37
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
Second
2 1 1 1
First
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.
英文伤不起啊!!
按照最优策略即每次只取一个的话,只需要比较n1和n2的值即可
AC代码:
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;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;}
- codeforces Rockethon 2015 - A. Game (= =)
- codeforces Rockethon 2014 A
- codeforces Rockethon 2015
- Codeforces Rockethon 2015
- CODEFORCES Rockethon 2015 B. Permutations
- Codeforces Rockethon 2015 解题报告
- codeforces Rockethon 2015 C. Second price auction 概率
- Codeforces Rockethon 2014 C题
- Rockethon 2014 A. Genetic Engineering
- codeforces a 24 game
- CodeForces - 513A Game
- Codeforces 213A Game
- Codeforces-513A-Game
- Rockethon 2015C
- codeforces 391E2 (【Codeforces Rockethon 2014】E2)
- codeforces 327A. Flipping Game
- CodeForces 293A Weird Game
- codeforces:A. The Great Game
- Android 自定义控件 轻松实现360软件详情页
- MapReduce练习(二)
- CSV介绍
- Core Animation(二)动画基础部分
- poj 3264 Balanced Lineup简单线段树
- codeforces Rockethon 2015 - A. Game (= =)
- UVA 11255 - Necklace (等价置换)
- 博弈论(高僧斗法)
- HDU-找新朋友-素数筛选
- Think in Java(八):持有对象
- CentOs安装的eclipse双击无反应
- OpenStack架构
- 《HTTP权威指南》读书笔记(6)-实体和编码
- HDU-汉诺塔V-移动次数