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的数学类算法题目。一个整数被称为k-smooth当且仅当它的最大素因子不大于k,给定N和K,计算出1 - N中有多少个整数是k-smooth。1 , 1 <= K <= 1000.
SRM2Multi dumper for hsap
omron系列CPM1/CPM1A/CPM2A/CPM2C/SRM1(-V2) PLC编程手册pdf,omron系列CPM1/CPM1A/CPM2A/CPM2C/SRM1(-V2) PLC编程手册
SAP SRM 介绍
Driver HASP SRM emulator (x86)
版本: 1.0.0 作者: Semen Zhydenko ... BridgeCrossingOptimized.java - SRM 146 DIV 2,1000 点问题,时间复杂度 O(n^(n^2))。 BridgeCrossingBest.java - SRM 146 DIV 2,1000 点问题,时间复杂度 O(n)。
srm后端JAVA 供应商平台管理 标准物资开票表 bus_standard_invoice_out增加freeze_quantity(冻结数量这一列)。 标准物资开票表 bus_standard_invoice_out的主键为{行项目、采购订单号、物料凭证}。 标准物资...
多年SRM实施经验总结,对希望从事SRM实施或规划的同学们有帮助
分块描述SRM系统的作用:寻源、协同和考核 涉及具体的业务用途,供前期规划作参考,可根据实际情况调整,再考虑如何实现
ASP SRM USB Command Line Dumper Instructions. HASP SRM USB命令行转储指令。 WARNING!!! Before make dump from dongle make sure that you install the ...2. 2. Execute h7dmp.exe file. 执行h7dmp.exe文件。
HASP_SRM_Runtime_setup
简叙什么是SRM,SRM解决什么问题,SRM有用途,SRM功能等
SRM210 (PA)SAP SRM Server Configuration (Col92) Configuration
SRM空间富模型隐写分析算法,选区高维特征,使用集成分类器进行训练
SRM210+(PA)SAP+SRM+Server+Configuration+(Col92) 开发配置
SRM Overview中文版让你更直观更容易了解SRM是什么,能做什么
SRM影像分割算法的matlab程序,主函数SRM_new
不仅可以阅读srm格式文件,还可以制作文档。完全绿色破解,是一款不错的srm阅读器。
为解决西山煤电集团东曲矿异步电机转子切电阻调速2JK-2.5×1.2型提升机可靠性差、耗能严重、成本高、效率低等缺陷,采用SRM结构调速控制提升机运行。SRM结构利用磁阻最小原理进行工作,由磁极绕组、不对称的拓扑等结构...
HASP SRM加密狗简介,阿拉丁公司的各种加密够简介