A10166 | Wizards' Duel
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Harry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of the corridor of length $l$ . Two opponents simultaneously charge a deadly spell in the enemy. We know that the impulse of Harry's magic spell flies at a speed of $p$ meters per second, and the impulse of You-Know-Who's magic spell flies at a speed of $q$ meters per second.
The impulses are moving through the corridor toward each other, and at the time of the collision they turn round and fly back to those who cast them without changing their original speeds. Then, as soon as the impulse gets back to it's caster, the wizard reflects it and sends again towards the enemy, without changing the original speed of the impulse.
Since Harry has perfectly mastered the basics of magic, he knows that after the second collision both impulses will disappear, and a powerful explosion will occur exactly in the place of their collision. However, the young wizard isn't good at math, so he asks you to calculate the distance from his position to the place of the second meeting of the spell impulses, provided that the opponents do not change positions during the whole fight.
The impulses are moving through the corridor toward each other, and at the time of the collision they turn round and fly back to those who cast them without changing their original speeds. Then, as soon as the impulse gets back to it's caster, the wizard reflects it and sends again towards the enemy, without changing the original speed of the impulse.
Since Harry has perfectly mastered the basics of magic, he knows that after the second collision both impulses will disappear, and a powerful explosion will occur exactly in the place of their collision. However, the young wizard isn't good at math, so he asks you to calculate the distance from his position to the place of the second meeting of the spell impulses, provided that the opponents do not change positions during the whole fight.
输入格式
The first line of the input contains a single integer $l$ ( $1<=l<=1000$ ) — the length of the corridor where the fight takes place.
The second line contains integer $p$ , the third line contains integer $q$ ( $1<=p,q<=500$ ) — the speeds of magical impulses for Harry Potter and He-Who-Must-Not-Be-Named, respectively.
The second line contains integer $p$ , the third line contains integer $q$ ( $1<=p,q<=500$ ) — the speeds of magical impulses for Harry Potter and He-Who-Must-Not-Be-Named, respectively.
输出格式
Print a single real number — the distance from the end of the corridor, where Harry is located, to the place of the second meeting of the spell impulses. Your answer will be considered correct if its absolute or relative error will not exceed $10^{-4}$ .
Namely: let's assume that your answer equals $a$ , and the answer of the jury is $b$ . The checker program will consider your answer correct if .
Namely: let's assume that your answer equals $a$ , and the answer of the jury is $b$ . The checker program will consider your answer correct if .
输入输出样例
输入 #1
100 50 50
输出 #1
50
输入 #2
199 60 40
输出 #2
119.4
In the first sample the speeds of the impulses are equal, so both of their meetings occur exactly in the middle of the corridor.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted