Codeforces Round #327 (Div. 2) (A. Wizards' Duel 简单数学)

54 篇文章 0 订阅
A. Wizards' Duel
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 lengthl. Two opponents simultaneously charge a deadly spell in the enemy. We know that the impulse of Harry's magic spell flies at a speed ofp meters per second, and the impulse of You-Know-Who's magic spell flies at a speed ofq 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.

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 integerq (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 exceed10 - 4.

Namely: let's assume that your answer equals a, and the answer of the jury isb. The checker program will consider your answer correct if.

Sample test(s)
Input
100
50
50
Output
50
Input
199
60
40
Output
119.4
Note

In the first sample the speeds of the impulses are equal, so both of their meetings occur exactly in the middle of the corridor

题意:两个人在直线上相向行驶,相遇后返回各自的起点,然后在相向行驶,问第二次相遇的时候左边的人到相遇点的距离

思路:两个人第二次相遇,两人相当于走了3*L的距离,那么我们可以计算第二次相遇的时间是3*L/(v1+v2) ,两个人第一次相遇后回到各自起点的时间是2*L/(v1+v2)

所以,回到起点后在到第二次相遇的时间是3*L/(v1+v2)-2*L/(v1+v2)==L/(v1+v2),所以是v1*L/(v1+v2)

#include<bits/stdc++.h>
using namespace std;
const int maxn=4011;
const int inf=1<<27;
#define LL long long
#define P pair<int,int>
#define pb push_back
#define cl(a,b) memset(a,b,sizeof(a));

int main(){
    double L,p,q;
    while(~scanf("%lf%lf%lf",&L,&p,&q)){
        printf("%lf\n",(L*p)/(p+q));
    }
    return 0;
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值