编程介的小学生 2017-08-20 09:43 采纳率: 20.5%
浏览 709
已采纳

Rout 66

Problem Description
While the Romans may have had a fancy number system, the Visigoths (led by Alareiks, known now as Alaric I) managed to take Rome on August
24, 410. This was the first time that Rome had been taken by foreign troops in eight hundred years.

You will simulate a considerably less bloody (and less realistic) rout of soldiers by a potentially overwhelming force.

Consider a group of invaders of strength I, and an opposing force of strength J, with distance D between them and a defensive stronghold of strength
S. The Routing Force F of the invaders can be calculated as their strength times the distance:

F = ID

and the Blocking Force B of the defenders can be calculated as their strength times the square of their defenses:

B = JS2

If F is less than or equal to B, the invaders' rout fails, and they are driven off. If F is greater than B, the rout is successful, all defenders of the
stronghold are driven off, and the invaders can continue. However, their strength is reduced by removing a fraction equal to the ratio of the
defenders' Blocking Force to their Routing Force for that attack. The resulting number should be rounded up to the nearest integer, to ensure that a
successful rout leaves at least one soldier:

Inew = ?I(1 - B/F)?

If the invaders make it through a stronghold, its location is considered the starting point for calculations regarding the next group of defenders, and so
on, until either the invading force makes it all the way through the defenders or is completely routed.

Your goal is to determine whether or not a given invading force can make it through a particular gauntlet of defenders.

For the purposes of simplification, all defending strongholds in this simulation are considered to be in a straight line from the starting position of the
invaders, and must be encountered in order from nearest to furthest away. No strongholds will be in the same location in a given set of data.

Input
Input to this problem will begin with a line containing a single integer N (1 ≤ N ≤ 100) indicating the number of data sets. Each data set consists of
the following components:

A line containing a single integer E (1 ≤ E ≤ 20) indicating the number of defensive strongholds in the data set;
A series of E lines, each with three integers D, J, S (1 ≤ D, J ≤ 10000; 1 ≤ S ≤ 50) separated by spaces representing the strongholds. D is the
distance of the stronghold from the invaders' starting position; remember that all strongholds are considered to be in a straight line from
the invaders' starting position, and must be encountered in order from nearest to furthest away. J and S represent the strength of the
defenders and the stronghold, respectively, as in the above equation; and
A line containing a single integer I (1 ≤ I ≤ 30000) representing the strength of the invading force.

Output
For each data set, print "ROUT!" if the invaders make it through all of the strongholds, or "RETREAT!" if the invaders cannot make it through all of the
strongholds.

Sample Input
2
1
10 10 5
100
2
75 100 5
10 10 5
50

Sample Output
ROUT!
RETREAT!

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-09-01 15:54
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看