编程介的小学生 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条回答

    报告相同问题?

    悬赏问题

    • ¥50 易语言把MYSQL数据库中的数据添加至组合框
    • ¥20 求数据集和代码#有偿答复
    • ¥15 关于下拉菜单选项关联的问题
    • ¥20 java-OJ-健康体检
    • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
    • ¥15 使用phpstudy在云服务器上搭建个人网站
    • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
    • ¥15 vue3+express部署到nginx
    • ¥20 搭建pt1000三线制高精度测温电路
    • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况