2013暑假集训B组训练赛第二场 - A Bus Game

本文介绍了一个名为BusGame的游戏,分析了游戏规则及胜负条件。游戏中两位玩家轮流从一堆硬币中取出价值220日元的硬币组合,具体策略包括优先取100日元硬币或10日元硬币等。
A - Bus Game
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

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 Input

Input
2 2
Output
Ciel
Input
3 22
Output
Hanako



很简单的循环,判断
#include <cstdio>

int x, y;

int main()
{
    while(~scanf("%d%d",&x,&y))
    {
        while(x >= 0&& y>=0)
        {
            if(x>=2 && y >= 2)
            {
                x -= 2;
                y -= 2;
            }
            else if(x==1 && y >= 12)
            {
                x -= 1;
                y -= 12;
            }
            else if(x== 0 && y>=22)
            {
                y -= 22;
            }
            else
            {
                puts("Ciel");
                break;

            }


            if(y>=22)
            {
                y -= 22;
            }
            else if(y>=12 && x >=1)
            {
                x -= 1;
                y -= 12;
            }
            else if(x>= 2 && y >=2)
            {
                x -= 2;
                y -= 2;
            }
            else
            {
                puts("Hanako");
                break;

            }
        }
    }

}

 



转载于:https://www.cnblogs.com/wejex/p/3219317.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值