A8539 | Plane of Tanks: Duel
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vasya plays the Plane of Tanks.
Tanks are described with the following attributes:
- the number of hit points;
- the interval between two gun shots (the time required to recharge the gun);
- the probability that the gun shot will not pierce armor of the enemy tank;
- the damage to the enemy's tank.
The gun damage is described with a segment $[l,r]$ , where $l$ and $r$ are integer numbers. The potential gun damage $x$ is chosen with equal probability among all integer numbers of the segment $[l,r]$ . If the shot pierces the armor of an enemy's tank then the enemy loses $x$ hit points. If the number of hit points becomes non-positive then the enemy tank is considered destroyed.
It is possible that the shot does not pierce the armor of a tank. In this case the number of hit points doesn't change. The probability that the armor will not be pierced is considered as the shooting tank attribute and does not depend on players' behavior.
The victory is near and there is only one enemy tank left. Vasya is ready for the battle — one more battle between the Good and the Evil is inevitable! Two enemies saw each other and each of them fired a shot at the same moment... The last battle has begun! Help Vasya to determine what is the probability that he will win the battle by destroying the enemy tank?
If both tanks are destroyed (after simultaneous shots), then Vasya is considered a winner. You can assume that each player fires a shot just after the gun recharge and each tank has infinite number of ammo.
Tanks are described with the following attributes:
- the number of hit points;
- the interval between two gun shots (the time required to recharge the gun);
- the probability that the gun shot will not pierce armor of the enemy tank;
- the damage to the enemy's tank.
The gun damage is described with a segment $[l,r]$ , where $l$ and $r$ are integer numbers. The potential gun damage $x$ is chosen with equal probability among all integer numbers of the segment $[l,r]$ . If the shot pierces the armor of an enemy's tank then the enemy loses $x$ hit points. If the number of hit points becomes non-positive then the enemy tank is considered destroyed.
It is possible that the shot does not pierce the armor of a tank. In this case the number of hit points doesn't change. The probability that the armor will not be pierced is considered as the shooting tank attribute and does not depend on players' behavior.
The victory is near and there is only one enemy tank left. Vasya is ready for the battle — one more battle between the Good and the Evil is inevitable! Two enemies saw each other and each of them fired a shot at the same moment... The last battle has begun! Help Vasya to determine what is the probability that he will win the battle by destroying the enemy tank?
If both tanks are destroyed (after simultaneous shots), then Vasya is considered a winner. You can assume that each player fires a shot just after the gun recharge and each tank has infinite number of ammo.
输入格式
The first line contains five integer numbers separated with spaces describing Vasya's tank: the number of hit points $hp$ $(10<=hp<=200)$ , the interval between two shots $dt$ $(1<=dt<=30)$ , gun damage segment $l$ and $r$ $(10<=l<=r<=100)$ , the probability that the enemy's tank armor will not be pierced $p$ $(0<=p<=100)$ (percents).
The second line describes the tank of Vasya's enemy in the same format.
The second line describes the tank of Vasya's enemy in the same format.
输出格式
Print the only number with absolute or relative error no more than $10^{-4}$ — probability of Vasya's victory.
输入输出样例
输入 #1
100 3 50 50 0 100 3 50 50 0
输出 #1
1.000000
输入 #2
100 3 50 50 0 100 2 48 50 0
输出 #2
0.888889
输入 #3
100 3 50 50 0 100 1 50 50 50
输出 #3
0.500000
In the first example both tanks are destroyed at once after the second shot. The probability of destroying the enemy tank is $1$ .
In the second example Vasya's enemy tank fires the second shot before Vasya's tank, but has no time for the third shot. In order to destroy Vasya's tank it is necessary to fire two shots with damage 50. The probability of that event is  = . Otherwise, Vasya wins.
In the third example Vasya's enemy tank fires three shots with probability of armor piercing $0.5$ . In order to destroy Vasya's tank it is necessary that at least 2 of 3 shots pierce the armor of Vasya's tank. The probability of this event is $0.5$ .
In the second example Vasya's enemy tank fires the second shot before Vasya's tank, but has no time for the third shot. In order to destroy Vasya's tank it is necessary to fire two shots with damage 50. The probability of that event is  = . Otherwise, Vasya wins.
In the third example Vasya's enemy tank fires three shots with probability of armor piercing $0.5$ . In order to destroy Vasya's tank it is necessary that at least 2 of 3 shots pierce the armor of Vasya's tank. The probability of this event is $0.5$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted