`
369540808
  • 浏览: 194257 次
文章分类
社区版块
存档分类
最新评论

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


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics