A. Bus Game

来源:互联网 发布:爬虫抓取淘宝销量数据 编辑:程序博客网 时间:2024/04/29 21:01

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

The first line contains two integers x (0 ≤ x ≤ 106) and y (0 ≤ y ≤ 106), separated by a single space.

Output

If Ciel wins, print "Ciel". Otherwise, print "Hanako".

Sample test(s)
input
2 2
output
Ciel
input
3 22
output
Hanako
Note

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;}


原创粉丝点击