SRM 598 DIV2 1000 FoxAndFencingEasy



 
Problem Statement
    Fox Ciel is playing a board game with her friend Squirrel Liss. The game is played on an infinite strip of paper. The strip of paper is divided into consecutive cells. Each cell has an integer coordinate. Formally, for each integer i, the left neighbor of cell i is cell (i-1) and the right neighbor of cell i is cell (i+1).




Each of the players has a single token called the fencer. At the beginning of the game, Ciel's fencer is in cell 0 and Liss's fencer is in cell d. Each of the fencers has a limit: its maximum move length. For Ciel's fencer the maximum move length is mov1 and for Liss's fencer it is mov2.




The players take alternating turns. Ciel goes first. In each turn the current player moves her fencer. The distance between the original cell and the destination cell must be at most equal to the fencer's maximum move length. (It is also allowed to leave the fencer in the same cell.) If the current player moves her fencer into the cell with the other fencer, the current player's fencer scores a hit and wins the game.




You are given the ints mov1, mov2, and d. Return "Ciel" (quotes for clarity) if Fox Ciel has a winning strategy, "Liss" if Squirrel Liss has a winning strategy, and "Draw" otherwise.
Definition
   
Class: FoxAndFencingEasy
Method: WhoCanWin
Parameters: int, int, int
Returns: string
Method signature: string WhoCanWin(int mov1, int mov2, int d)
(be sure your method is public)
    
Constraints
- mov1 will be between 1 and 100,000,000, inclusive.
- mov2 will be between 1 and 100,000,000, inclusive.
- d will be between 1 and 100,000,000, inclusive.
Examples
0)
   
1
58
1
Returns: "Ciel"
Ciel can win in her first turn by moving her fencer one cell to the right.
1)
   
100
100
100000000
Returns: "Draw"
Liss can avoid getting hit forever by repeating Ciel's moves. For example, whenever Ciel moves her fencer 47 cells to the right, Liss also moves her fencer 47 cells to the right. Ciel has a similar strategy: in her first turn she can move her fencer arbitrarily and in each of the following turns she will repeat Liss's previous move. Therefore the game ends in a draw.
2)
   
100
150
100000000
Returns: "Draw"
3)
   
100
250
100000000
Returns: "Liss"
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.

至少得大于两倍才可以安全的追到另一个人

class FoxAndFencingEasy {
public:
    string WhoCanWin(int mov1, int mov2, int d)
    {
        string Ciel("Ciel"),Liss("Liss"),Draw("Draw");
        if(mov1>=d) return Ciel;
        else if(mov1>2*mov2) return Ciel;
        else if(mov2>2*mov1) return Liss;
        else return Draw;
    }
}; 


  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值