大水题--CodeForces - 591A Wizards' Duel
2015-11-08 22:06
471 查看
Description
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 qmeters
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.
Input
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.
Output
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
.
Sample Input
Input
Output
Input
Output
Hint
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的速度发出魔法,魔法第一次碰撞后弹开,到达魔法师身边后再一次发射相同速度的魔法,问第二次碰撞的位置。
解法:
相向问题求相遇点,第一次相遇点和反弹后第二次相遇的点实际上是一个位置
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 qmeters
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.
Input
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.
Output
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
.
Sample Input
Input
100 50 50
Output
50
Input
199 60 40
Output
119.4
Hint
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 <cstdio> int main() { double l, p, q; while(~scanf("%lf%lf%lf", &l, &p, &q)) { printf("%.8lf\n", l/(p+q)*p); } return 0; }
相关文章推荐
- bzoj1626【Usaco2007 Dec】Building Roads 修建道路
- UItabbarViewController取消默认蓝色与设置标题颜色
- [iOS基础]从使用UIPopoverController到UIViewController弹出模态
- Web前端 - Easy UI的Tree插件和DataGrid插件实战
- WeakReference &&reference quene &&GC
- android 导入module,报failed to find build tools 错解决方案
- Android高级之Volley框架(二):JsonRequest
- 【DP】 HDU 3229 Jinyuetuan Puzzle
- Unable to get setting value Parameter name: profileName
- 接口 ValueStack:com.opensymphony.xwork2.util
- UINavigationController 总结
- __builtin_expect 解惑
- lightoj Answering Queries 1369 (数学转换&&技巧)
- HDU 1560DNA sequence
- 使用VS2010调用QtDesigner设计的UI文件,并实现控件功能
- EasyUI - 后台管理系统 - 增加,删除,修改
- IOS UISwitch 感觉官方提供的拓展性不够好,老感觉这个东西项目中用到需要自己定制
- UITableView 滑动自动加载更多数据
- Gson 解析 json中 value为数组
- Light OJ 1369 - Answering Queries 【规律】