A. Bus Game
来源:互联网 发布:爬虫抓取淘宝销量数据 编辑:程序博客网 时间:2024/04/29 21:01
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
- Initially, there is a pile that contains x 100-yen coins and y 10-yen coins.
- They take turns alternatively. Ciel takes the first turn.
- In each turn, they must take exactly 220 yen from the pile. In Ciel's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 100-yen coins. In Hanako's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 10-yen coins.
- If Ciel or Hanako can't take exactly 220 yen from the pile, she loses.
Determine the winner of the game.
The first line contains two integers x (0 ≤ x ≤ 106) and y (0 ≤ y ≤ 106), separated by a single space.
If Ciel wins, print "Ciel". Otherwise, print "Hanako".
2 2
Ciel
3 22
Hanako
In the first turn (Ciel's turn), she will choose 2 100-yen coins and 2 10-yen coins. In the second turn (Hanako's turn), she will choose 1 100-yen coin and 12 10-yen coins. In the third turn (Ciel's turn), she can't pay exactly 220 yen, so Ciel will lose.
解题说明:此题类似于轮流取数,模拟两个人取硬币的过程,直到一方无法再取,在取得过程中,为了节省时间,可以把币值之和满足220的硬币都去掉。
#include<iostream>#include<cstdio>using namespace std;int main(){int x, y;scanf("%d%d", &x, &y);while (1){if (x >= 2 && y >= 2){x -= 2;y -= 2;}else if (x >= 1 && y >= 12){x -= 1;y -= 12;}else if (y >= 22){y -= 22;}else{printf("Hanako\n");break;}if (y >= 22){y -= 22;}else if (x >= 1 && y >= 12){x -= 1;y -= 12;}else if (x >= 2 && y >= 2){x -= 2;y -= 2;}else{printf("Ciel\n");break;}}return 0;}
- A. Bus Game
- codeforces#71 A Bus Game----DFS
- 【水模拟】#71 A. Bus Game
- Codeforces Round #436 (Div. 2) A.Fair Game B.Polycarp and Letters C. Bus D.Make a Permutation!
- On a bus
- 475A Bayan Bus
- A. Bayan Bus
- 【CODEFORCES】 A. Bayan Bus
- A.Bus to Udayland
- A. Bus to Udayland
- A - Bus to Udayland
- A. Bus to Udayland
- A Game
- A Game
- A. Game
- A. Game
- A Federared Service Bus Infrastructure
- A. Vasya and the Bus
- 强调一下数据恢复需要注意的几个事项
- Linux多线程编程(不限Linux)
- [LeetCode] Validate Binary Search Tree
- android三种传输方案分析+一个注册登录例子
- 储量估算
- A. Bus Game
- Linux下校园网锐捷认证方法
- html map 标签的使用
- Android 实现分享功能代码
- 使用diff比较两个文件夹
- assert()函数用法总结
- Java vs C++ (12)member initial style
- ubuntu 安装 QT 及绘图插件 未完
- android网络状态判断(wifi、3G、2G)