【水模拟】#71 A. Bus Game

A. Bus Game
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.


原先看到这个题说谁赢谁输还以为是博弈……意思是有x枚100元硬币、y枚10元硬币,两个人轮流取钱每次取220元,Ciel(希尔)每次尽可能多的取100元硬币,Hanako(花子)则每次尽可能多的取10元硬币(意味不明……),然后问谁第一次没法取了另一个人就赢了。

那么我们就模拟他们取硬币的过程吧。

希尔(Ciel)的话,100元不小于2个的情况下就取2个加上2个10元的,不足2个就取光剩下的10元来凑

Hanako反之,同理。

自然,当总钱数不足220或者10元硬币不足2个的时候失败。

代码如下:

#include <cstdio>
#include <string>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
// http://codeforces.com/contest/79
// Bus Game
int main()
{
	int x,y,turn=1;	//1-Ciel 2-Hanako
	cin>>x>>y;
	while(turn)
	{
		if(y<2 || 100*x+10*y<220) break;
		if(turn==1)
		{
			if(x>=2)x-=2,y-=2;
			else if(x==1)x-=1,y-=12;
			else if(x==0)y-=22;
		}
		else if(turn==2)
		{
			if(y>=22)y-=22;
			else if(y>=12)y-=12,x-=1;
			else if(y>=2)y-=2,x-=2;
		}
		turn = 3-turn;
	}
	if(turn==1)printf("Hanako");
	else printf("Ciel");
	return 0;
} 





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

糖果天王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值