Codeforces Round #327 (Div. 2)A. Wizards' Duel
来源:互联网 发布:网络语打卡失败 编辑:程序博客网 时间:2024/06/05 19:54
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 pmeters 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 first line of the input contains a single integer l (1 ≤ l ≤ 1 000) — 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.
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 .
1005050
50
1996040
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.
题目大意:
哈利波特和伏地魔在长度为l的走廊上决斗,左边的人以p的速度发出魔法,右边的人以q的速度发出魔法,魔法第一次碰撞后弹开,到达魔法师身边后再一次发射相同速度的魔法,问第二次碰撞的位置。
解法:
烦了这么长其实就是相向问题求相遇点,水到不能再水的模拟题
#include "iostream"using namespace std;int main(int argc, char* argv[]){ double s,v1,v2; cin>>s>>v1>>v2; cout<<s/(v1+v2)*v1<<endl; return 0;}
- Codeforces Round #327 (Div. 2)A. Wizards' Duel
- Codeforces Round #327 (Div. 2) A. Wizards' Duel 反思
- Codeforces Round #327 (Div. 2) (A. Wizards' Duel 简单数学)
- Codeforces Round #327 (Div. 2) A. Wizards' Duel
- Codeforces Round #327 (Div. 2)A. Wizards' Duel
- Codeforces Round #327 (Div. 2) A. Wizards' Duel(水)
- Codeforces Round #327 (Div. 2)A. Wizards' Duel
- cf #327 Div.2 Problem A Wizards' Duel
- CodeForces-591A Wizards' Duel
- Codeforces 591A Wizards' Duel
- Codeforces 591A Wizards' Duel
- codeforces 591A Wizards' Duel
- 大水题--CodeForces - 591A Wizards' Duel
- A. Wizards' Duel
- Code Forces 591 A. Wizards' Duel(水~)
- Codeforces Round #327 (div.2)(A B C D)
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #174 (Div. 2) Problem A
- 使用Postman进行outh2认证
- openfire3.10.2部署实时步骤
- jail brak 获取当前安装app列表
- 大整数相乘 分治法
- 工薪青年如何通过组合投资来获得长期稳定10%收益?
- Codeforces Round #327 (Div. 2)A. Wizards' Duel
- 媒体查询
- Android 自定义View,实现滚动选择器PickerView
- 第36个故事
- XAMPP Error:Apache shutdown unexpectedly 解决方案
- Java Web项目中文乱码
- VS c2065 未声明的标识符 另外一种解决方案
- WAMP环境搭建
- Codeforces Round #327 (Div. 2)B. Rebranding