SRM 598 DIV2 1000 FoxAndFencingEasy
2013-11-29 17:22
471 查看
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;
}
};
相关文章推荐
- Topcoder SRM 561 DIV2 1000 FoxAndTouristFamilies
- Topcoder SRM 566 DIV2 1000 FencingPenguinsEasy
- SRM 552 - 500 FoxAndFlowerShopDivOne
- SRM 611 DIV2 1000 ElephantDrinkingEasy
- [最小割] SRM 590 div1 FoxAndCity
- TopCoder SRM 649 Div2 Problem 1000 - XorSequenceEasy (思维)
- TopCoder SRM 651 Div2 Problem 500 - FoxAndSouvenirTheNext (DP)
- [距离限制模型 & 最小割]TopCoder SRM590 DIV1 1000. FoxAndCity
- SRM 608 div2 500 MysticAndCandiesEasy
- (水题)TC SRM 441 DIV 500 PaperAndPaintEasy
- srm 307 div2 1000(数论,枚举)
- TOPCODER SRM 686 div2 1000
- Codeforces Round #290 (Div. 2) B. Fox And Two Dots dfs
- Codeforces Round #290 (Div. 1)A. Fox And Names
- srm 656 div2 1000(dp+组合)
- Codeforces Round #228 (Div. 2) D - Fox and Minimal path
- SRM 649 div2 1000
- CF #228 div1 B. Fox and Minimal path
- Topcoder SRM 585 DIV2 解题报告 //缺1000
- Codeforces Round #245 (Div. 2) A - Points and Segments (easy)