编程介的小学生 2019-06-25 22:14 采纳率: 20.5%
浏览 138

计算是否可以成功地进行塔防,怎么采用C语言的程序的设计的编写的技术来完成的

Tower Defense(TD) is a kind of rpg game in the warcraft3, which is very popular. in this game, you can build some tower near the road, and the enemy come along the road. when the enemy in the tower's attack range, the tower can attack the enemy. and each attack the enemy's life will reduce as the damage of the tower. When the enemy's life less than or equals 0, it dies. The mission of TD is kill all the enemies.

Now let's consider an easy situation. In the X-Y reference frame, there are n towers, each has a coordinate (x,y), an attack range, an attack type. m enemies come from (0,0) to (-10,0), in a line, with the length 2, and the enemies are come one by one. For example, in time 0 the all m enemies in (0,0), then in time 1 the first enemy go to (-2,0), in time 2 the first enemy go to (-4,0), the second enemy go to (-2,0), and so on, when an enemy go to (d,0)(d<=-10), we failed, even if it is still poisoned at this time, or we succeed. when the eneny in (0,0) and (d,0)(d<=-10), the tower can not attack, even if the enemy is in the tower's attack range. To simplify the problem, at each time each tower can attack once. when more than one enemy in its range, we can control it to attack any one, or even control it not attack, with the best strategy.

There are three attack type:
common attack: when an enemy is attacked, the life is reduced by the damage of the tower.
poison attack: when an enemy is attacked, the life is first reduced by the damage of the tower. And in the next 2 times, the enemy's life will be reduced by the poison damage. if the enemy poisoned more than once, the damage will not double. For example, the enemy's life is 200, tower's damage is 100, poison damage is 20, in time 1, the enemy be attacked, then in time 1, the enemy's life is 100(200-100), in time 2 the enemy's life is 80(100-20), in time 3 the enemy's life is 60(100-20).
freezing attack: when an enemy is attacked, the life is first reduced by the damage of the tower. And in next 2 times, the enemy's speed is reduced by half. For example, an enemy be attacked in (-2,0), then it first go to (-3,0), (-4,0), then go to (-6,0), the freezing can not double, too. The problem is give us n towers and m enemies, can we successful in the tower defense?

Input:

The first line of the input is n, m,life and poison_damage, the number of the towers, the number of the enemies, the life of enemy and the poison damage of poison attack. n<6, m<6, life<1000, 0<poison_damage<1000. Next n lines is the description of each tower, the first 5 number is x, y, range, damage, attack_type, the attack_type can be 0, 1, 2, which denote common attack, poison attack, freezing attack. 0<damage<1000. All are integers. a line with n=m=life=0 denoted the end of input.

Output:

If we succeed in the tower defense, output "succeed", or output "fail", in a separate line.

Sample Input:
1 1 10 5
1 1 20 10 0
1 1 20 5
-2 0 1 10 0
2 2 40 5
-3 0 1 30 0
-7 0 1 10 0
0 0 0 5
Sample Output:
succeed
fail
succeed

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 chaquopy python 安卓
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 有没有帮写代码做实验仿真的
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥30 vmware exsi重置后登不上
    • ¥15 易盾点选的cb参数怎么解啊
    • ¥15 MATLAB运行显示错误,如何解决?
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容
    • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题