Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题

本文介绍了一个基于物理原理的编程问题,即在一场魔法对决中,两个魔法师分别从走廊两端施放咒语,需要计算这两个咒语第二次相遇的位置。通过计算咒语的速度和走廊的长度,可以得出咒语第二次相遇的确切位置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. Wizards' Duel

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/591/problem/A

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 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.

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

100
50
50

Sample Output

50

HINT

 

题意

在长度为l的跑道上,左边人的速度是a,右边人的速度是b,然后问你相遇在哪儿

题解:

物理题啦,先算出相遇时间,然后a*t就好了

代码

 

#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
    double a,b,c;
    cin>>a>>b>>c;
    double t = a/(b+c);
    printf("%.12lf\n",t*b);
}

 

转载于:https://www.cnblogs.com/qscqesze/p/4910207.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值