关闭

CodeForces 624A Save Luke(相对,数学)

111人阅读 评论(0) 收藏 举报
分类:
Description
Luke Skywalker got locked up in a rubbish shredder between two presses. R2D2 is already working on his rescue, but Luke needs to stay alive as long as possible. For simplicity we will assume that everything happens on a straight line, the presses are initially at coordinates 0 and L, and they move towards each other with speed v1 and v2, respectively. Luke has width d and is able to choose any position between the presses. Luke dies as soon as the distance between the presses is less than his width. Your task is to determine for how long Luke can stay alive.

Input
The first line of the input contains four integers d, L, v1, v2 (1 ≤ d, L, v1, v2 ≤ 10 000, d < L) — Luke's width, the initial position of the second press and the speed of the first and second presses, respectively.

Output
Print a single real value — the maximum period of time Luke can stay alive for. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

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

Sample Input
Input
2 6 2 2
Output
1.00000000000000000000
Input
1 9 1 2
Output
2.66666666666666650000
Hint
In the first sample Luke should stay exactly in the middle of the segment, that is at coordinates [2;4], as the presses move with the same speed.

In the second sample he needs to occupy the position . In this case both presses move to his edges at the same time.

代码:

#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
	int d,l,v1,v2;
	while(scanf("%d %d %d %d",&d,&l,&v1,&v2)!=EOF)
	{
		double ans,sum;
		sum=(double)l-(double)d;
		ans=sum/(double)(v1+v2);
		printf("%.7lf\n",ans);
	}
	return 0;
}
题意:给你一个初始距离和一个最终距离。初始距离有个人以v1速度最终距离,同时最终距离有个粉碎机以v2向人冲去。问这个人能活多久。

思路:简单的数学题相对距离除以相对速度就行。

0
0
查看评论
发表评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场

【CodeForces】624A - Save Luke(数学小问题)

点击打开题目 A. Save Luke time limit per test 1 second memory limit per test ...
  • wyg1997
  • wyg1997
  • 2016-06-15 07:50
  • 136

CodeForces 624A Save Luke神庙大逃亡(暑期小练习)

神庙大逃亡(暑期小练习) Description LukeSkywalker got locked up in a rubbish shredder between two presses. R2D2...
  • shyazhut
  • shyazhut
  • 2016-06-01 21:05
  • 226

(二) P - P Save Luke 【数学】

P - P Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Sub...
  • bmicnj
  • bmicnj
  • 2016-06-01 09:32
  • 173

lucene开发必备工具luke介绍

原文地址: 做lucene开发的,免不了要和索引文件打交道,但是一些二进制的文件我们怎么去看,下面就要隆重的有请luke了 根据百度百科的说法:Luke是一个用于Lucene搜...
  • xiaogugood
  • xiaogugood
  • 2013-07-18 10:20
  • 1757

【Lucene01】索引的建立&Luke的配置使用

在Lucene对文本进行处理的过程中,可以大致分为三大部分: 1、索引文件:提取文档内容并分析,生成索引 2、搜索内容:搜索索引内容,根据搜索关键字得出搜索结果 3、分析内容:...
  • kevinelstri
  • kevinelstri
  • 2016-08-29 20:02
  • 578

Luke:Lucene索引查看工具

Luke介绍 Luke是一个方便的索引查看和诊断工具,可以访问Lucene构建的索引文件,显示和修改某些索引内容。能提供: 通过document编号或term浏览索引查看document内...
  • zbf8441372
  • zbf8441372
  • 2013-01-12 15:13
  • 8412

【codeforces 732E】【贪心 map乱搞】

传送门:http://codeforces.com/contest/732/problem/E 描述: E. Sockets time limit per t...
  • guhaiteng
  • guhaiteng
  • 2016-10-22 15:32
  • 548

取代人类医生?AI给你做的诊断你敢信吗

翻译 | ziqi zhang 编辑 | Donna,波波 Luke Oakden-Rayner 是澳大利亚知名学府阿德莱德大学的在读医学博士生、放射线学专家,曾发...
  • dQCFKyQDXYm3F8rB0
  • dQCFKyQDXYm3F8rB0
  • 2017-12-07 00:00
  • 1020

codeforces上一种应对大测试数据debug方法

接触codeforces时间不长,也就参加了10场左右。之前有次比赛就出现了wa了一道题,在比赛结束后看测试数据log时,发现出错的那组用例是个超过一万行输入的情况,codeforces上的测试数据无...
  • qq_29070399
  • qq_29070399
  • 2017-02-03 16:09
  • 770

2.Lucene3.6.2包介绍,第一个Lucene案例介绍,查看索引信息的工具lukeall介绍,Luke查看的索引库内容,索引查找过程

 1  Lucen目录介绍 2  lucene-core-3.6.2.jar是lucene开发核心jar包    contrib  目录存放,包含一些扩展jar包 ...
  • toto1297488504
  • toto1297488504
  • 2014-12-07 23:39
  • 2879
    个人资料
    • 访问:35957次
    • 积分:2744
    • 等级:
    • 排名:第15147名
    • 原创:248篇
    • 转载:13篇
    • 译文:0篇
    • 评论:4条