Codeforces Round #327 (Div. 2) A. Wizards' Duel(水)
2015-10-27 20:30
477 查看
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 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 test(s)
Input
Output
Input
Output
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.
大意:两个相对而行的人,给出长度L,速度P和速度Q,问相遇时P走了多长
思路:水题
ac代码:
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#define MAXN 100010
#define MOD 1000000007
#define LL long long
#define MAX(a,b) a>b?a:b
#define MIN(a,b)a>b?b:a
#define INF 0xfffffff
using namespace std;
int a[MAXN];
int v[MAXN];
int fab(int a)
{
return a>0?a:-a;
}
int main()
{
double l,p,q;
while(scanf("%lf%lf%lf",&l,&p,&q)!=EOF)
{
double s=l/(p+q);
printf("%lf\n",s*p);
}
return 0;
}
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 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 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.
大意:两个相对而行的人,给出长度L,速度P和速度Q,问相遇时P走了多长
思路:水题
ac代码:
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#define MAXN 100010
#define MOD 1000000007
#define LL long long
#define MAX(a,b) a>b?a:b
#define MIN(a,b)a>b?b:a
#define INF 0xfffffff
using namespace std;
int a[MAXN];
int v[MAXN];
int fab(int a)
{
return a>0?a:-a;
}
int main()
{
double l,p,q;
while(scanf("%lf%lf%lf",&l,&p,&q)!=EOF)
{
double s=l/(p+q);
printf("%lf\n",s*p);
}
return 0;
}
相关文章推荐
- UIButton 的 常用方法
- 【iOS】file not found: .../Build/Products/Debug-iphonesimulator file not found
- Multi-Threading: How to Create Threads in UE4
- An Introduction to UE4 Plugins
- ZOJ 2724 Windows Message Queue(二叉堆||优先队列)
- UE4 Plugins
- UIButton的一些属性和方法
- UIscrollView的属性及其协议方法
- PHP实现quicksort
- UItextfield的一些方法总结
- javax.persistence.TransactionRequiredException: Executing an update/delete query
- QtQuick手机滑动界面Demo
- Easyui 定制window窗口
- android6.0 蓝牙搜索不到设备 BluetoothAdapter.getDefaultAdapter().startDiscovery()不起作用
- IOS——UITextField自动适应键盘弹出
- IOS——UITextField自动适应键盘弹出
- iOS 【UIKit-NSTimer 的创建及运行循环模式】
- UIImageView变灰
- C#学习(6):DataSet构建EasyUI树结构
- request.getSession(false)