CF175D.Plane of Tanks: Duel
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
瓦西娅正在玩《坦克世界》(Plane of Tanks)。
每辆坦克具有以下属性:
- 生命值(Hit Points);
- 两次射击之间的间隔时间(即火炮装填所需时间);
- 射击命中后无法击穿敌方坦克装甲的概率;
- 对敌方坦克造成的伤害值。
火炮伤害以一个整数区间 ([l, r]) 表示,其中 (l) 和 (r) 均为整数。实际造成的伤害值 (x) 在区间 ([l, r]) 内的所有整数中等概率随机选取。若该次射击成功击穿敌方坦克装甲,则敌方坦克损失 (x) 点生命值;若敌方坦克剩余生命值变为非正值(即 (\leq 0)),则该坦克被判定为摧毁。
也存在射击未能击穿装甲的情况。此时,敌方坦克的生命值不发生变化。未击穿装甲的概率是射击方坦克自身的固有属性,与玩家操作行为无关。
胜利近在咫尺,目前战场上仅剩一辆敌方坦克。瓦西娅已整装待发——正义与邪恶之间最后一战不可避免!双方坦克彼此发现对方,并在同一时刻开火……最终决战就此打响!请帮助瓦西娅计算:他通过摧毁敌方坦克而赢得这场战斗的概率是多少?
若双方坦克在同时射击后均被摧毁,则瓦西娅仍被视为获胜者。你可以假设:每位玩家总是在火炮完成装填后立即开火,且每辆坦克弹药无限。
输入格式
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.
第一行包含五个用空格分隔的整数,描述瓦夏的坦克:生命值 hp(10 ≤ hp ≤ 200)、两次射击的时间间隔 dt(1 ≤ dt ≤ 30)、炮弹伤害区间 l 和 r(10 ≤ l ≤ r ≤ 100)、敌人坦克装甲未被击穿的概率 p(0 ≤ p ≤ 100)(百分比)。
第二行以相同格式描述瓦夏敌人的坦克。
输出格式
Print the only number with absolute or relative error no more than 10 - 4 — probability of Vasya's victory.
输出唯一数值(绝对或相对误差不超过 10−4)——即瓦西娅获胜的概率。
输入输出样例
输入#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.
在第一个例子中,两辆坦克都在第二次射击后同时被摧毁。摧毁敌方坦克的概率为 1。
在第二个例子中,瓦西娅的敌方坦克在瓦西娅的坦克之前发射第二发炮弹,但没有时间发射第三发炮弹。要摧毁瓦西娅的坦克,必须连续两次命中且每次造成 50 点伤害。该事件发生的概率为
=
。否则,瓦西娅获胜。
在第三个例子中,瓦西娅的敌方坦克以 0.5 的穿甲概率发射三发炮弹。要摧毁瓦西娅的坦克,必须有至少 2 发炮弹击穿瓦西娅坦克的装甲。该事件发生的概率为 0.5。
输入解题思路,AI测评打分。不知道怎么写?