cf591A Wizards' Duel
2 seconds
256 megabytes
standard input
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.
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 .
100
50
50
50
199
60
40
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.
sb模拟题
显然弹几次都是一样的
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
#define inf 0x7fffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
double l,a,b,t1;
int main()
{
scanf("%lf%lf%lf",&l,&a,&b);
t1=l/(a+b);
cout<<l-t1*b<<endl;
}
cf591A
cf591A Wizards' Duel的更多相关文章
- Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题
A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...
- codeforces 591A. Wizards' Duel 解题报告
题目链接:http://codeforces.com/problemset/problem/591/A 题目意思:其实看下面这幅图就知道题意了,就是Harry 和 He-Who-Must-Not-Be ...
- Codeforces Round #327 (Div. 2)-Wizards' Duel
题意: 在一条长度为l的走廊,两个人站在走廊的左右两端分别以p,q的速度走来,问他们相遇时离左端的距离是多少? 思路: 非常简单的暴力题,不解释. 代码如下: #include <iostrea ...
- CodeForces 591A Wizards' Duel
水题 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> us ...
- Codeforces Round #327 (Div. 2)
题目传送门 水 A - Wizards' Duel 题目都没看清就写了,1e-4精度WA了一次... /************************************************ ...
- CF:322D - Ciel and Duel 贪心 或者 DP 我用的贪心 。。难道sort跟qsort是不一样的么?
D. Ciel and Duel time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- Codeforces Round #114 (Div. 1) B. Wizards and Huge Prize 概率dp
B. Wizards and Huge Prize Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...
- Codeforces Round #114 (Div. 1) A. Wizards and Trolleybuses 物理题
A. Wizards and Trolleybuses Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...
- [codeforces167B]Wizards and Huge Prize
B. Wizards and Huge Prize time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...
随机推荐
- 数据的存储-NSKeyedArchiver和write to file介绍
数据的存储-NSKeyedArchiver和write to file介绍 首先介绍各个文件的作用-->讲解文件位置的查找方法-->介绍数据存储的方式:1.使用归档方式存储数据 2.wri ...
- myeclipse html乱码
myeclispe 中 html乱码 在页面的开头写上即可 <meta http-equiv="content-type" content="text/html; ...
- App 启动加载广告页面思路
需求 很多app(如淘宝.美团等)在启动图加载完毕后,还会显示几秒的广告,一般都有个跳过按钮可以跳过这个广告,有的app在点击广告页之后还会进入一个广告页面,点击返回进入首页.今天我们就来开发一个广告 ...
- 【转】string常用函数
原文地址:http://hi.baidu.com/baowup/blog/item/3a27465c86d71546faf2c066.html/cmtid/de1ef3f0de7554a0a40f52 ...
- POJ 1330 Nearest Common Ancestors(LCA模板)
给定一棵树求任意两个节点的公共祖先 tarjan离线求LCA思想是,先把所有的查询保存起来,然后dfs一遍树的时候在判断.如果当前节点是要求的两个节点当中的一个,那么再判断另外一个是否已经访问过,如果 ...
- UIWebView执行JS语句
示例网页: http://m.dianping.com/tuan/deal/moreinfo/11507109 移除该网页的返回按钮, 购买链接, 最底部的友情链接 代码: NSMutableStri ...
- 使用C++11 实现的线程池
最近打算做一个服务器端程序,每来一个客户端请求新开一个线程进行处理.在网上查了一些资料后,准备使用线程池来做这个东西.使用C++11新的库处理想线程问题比以前简单了许多,在网上找到一份线程池的实现,h ...
- bash shell学习-正则表达式基础 (笔记)
A gentleman is open-minded and optimistic; a small person is narrow-minded and pessimistic. "君子 ...
- Spring3.0提供的表达式语言spel
package com.zf.spel; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.D ...
- 中文版kendoUI API — Grid(一)
1.altRowTemplate 类型:Function | String 说明:提供表格行的交替模板,默认grid表格为每一个数据元素提供一个tr 注意:模板中最外层的html元素必须是<tr ...