Space Golf

题目连接:

http://codeforces.com/gym/100803/attachments

Description

You surely have never heard of this new planet surface exploration scheme, as it is being carried

out in a project with utmost secrecy. The scheme is expected to cut costs of conventional rovertype

mobile explorers considerably, using projected-type equipment nicknamed “observation

bullets”.

Bullets do not have any active mobile abilities of their own, which is the main reason of their

cost-efficiency. Each of the bullets, after being shot out on a launcher given its initial velocity,

makes a parabolic trajectory until it touches down. It bounces on the surface and makes another

parabolic trajectory. This will be repeated virtually infinitely.

We want each of the bullets to bounce precisely at the respective spot of interest on the planet

surface, adjusting its initial velocity. A variety of sensors in the bullet can gather valuable data

at this instant of bounce, and send them to the observation base. Although this may sound like

a conventional target shooting practice, there are several issues that make the problem more

difficult.

• There may be some obstacles between the launcher and the target spot. The obstacles

stand upright and are very thin that we can ignore their widths. Once the bullet touches

any of the obstacles, we cannot be sure of its trajectory thereafter. So we have to plan

launches to avoid these obstacles.

• Launching the bullet almost vertically in a speed high enough, we can easily make it hit

the target without touching any of the obstacles, but giving a high initial speed is energyconsuming.

Energy is extremely precious in space exploration, and the initial speed of the

bullet should be minimized. Making the bullet bounce a number of times may make the

bullet reach the target with lower initial speed.

• The bullet should bounce, however, no more than a given number of times. Although

the body of the bullet is made strong enough, some of the sensors inside may not stand

repetitive shocks. The allowed numbers of bounces vary on the type of the observation

bullets.

You are summoned engineering assistance to this project to author a smart program that tells

the minimum required initial speed of the bullet to accomplish the mission.

Figure D.1 gives a sketch of a situation, roughly corresponding to the situation of the Sample

Input 4 given below

Input

You can assume the following.

• The atmosphere of the planet is so thin that atmospheric resistance can be ignored.

• The planet is large enough so that its surface can be approximated to be a completely flat

plane.

• The gravity acceleration can be approximated to be constant up to the highest points a

bullet can reach.

These mean that the bullets fly along a perfect parabolic trajectory.

You can also assume the following.

• The surface of the planet and the bullets are made so hard that bounces can be approximated

as elastic collisions. In other words, loss of kinetic energy on bounces can be ignored.

As we can also ignore the atmospheric resistance, the velocity of a bullet immediately after

a bounce is equal to the velocity immediately after its launch.

• The bullets are made compact enough to ignore their sizes.

• The launcher is also built compact enough to ignore its height.

You, a programming genius, may not be an expert in physics. Let us review basics of rigid-body

dynamics.

• The horizontal velocity component of the bullet is kept constant during its flight when

atmospheric resistance is ignored. Thus the horizontal distance from the launcher is proportional

to the time elapsed.

• The vertical velocity component vy is gradually decelerated by the gravity. With the

gravity acceleration of g, the following differential equation holds during the flight.

dvy

Solving this with the initial conditions of vy = viy and y = 0 when t = 0, we obtain the

following.

The equation (4) tells that the bullet reaches the ground again when t = 2viy/g. Thus, the

distance of the point of the bounce from the launcher is 2vixviy/g. In other words, to make

the bullet fly the distance of l, the two components of the initial velocity should satisfy

2vixviy = lg.

• Eliminating the parameter t from the simultaneous equations above, we obtain the following

equation that describes the parabolic trajectory of the bullet.

For ease of computation, a special unit system is used in this project, according to which the

gravity acceleration g of the planet is exactly 1.0.

Output

The input consists of a single test case with the following format.

d n b

p1 h1

p2 h2

.

.

.

pn hn

The first line contains three integers, d, n, and b. Here, d is the distance from the launcher

to the target spot (1 ≤ d ≤ 10000), n is the number of obstacles (1 ≤ n ≤ 10), and b is the

maximum number of bounces allowed, not including the bounce at the target spot (0 ≤ b ≤ 15).

Each of the following n lines has two integers. In the k-th line, pk is the position of the k-th

obstacle, its distance from the launcher, and hk is its height from the ground level. You can

assume that 0 < p1, pk < pk+1 for k = 1, . . . , n − 1, and pn < d. You can also assume that

1 ≤ hk ≤ 10000 for k = 1, . . . , n.

Sample Input

343 3 2

56 42

190 27

286 34

Sample Output

11.08710

Hint

题意

你需要从(0,0)点扔出去一个球,恰好扔在(d,0)

而且这个球不能碰到任何一个障碍,最多在地上弹b次

问你速度最小为多少

题解:

我们可以物理一点去想,这个抛物线一定是靠着某一个障碍或者45°扔出去的

所以我们直接暴力枚举靠在哪一个障碍就好了

我们处理的时候,可以优化一下,可以直接把抛物线变成关于y轴对称的抛物线,然后把障碍都移到那儿

然后再判断

注意:精度有毒

代码

#include<bits/stdc++.h>
using namespace std; double d;
int n,b;
double p[20],h[20];
double eps = 1e-6;
double solve(int t)
{
double dis = d/t;
double p2[20],h2[20];
for(int i=1;i<=n;i++)
{
p2[i]=p[i];
while(p2[i]>=dis)
p2[i]-=dis;
p2[i]-=dis/2.0;
h2[i]=h[i];
}
double ans = 1e9;
for(int i=1;i<=n;i++)
{
double A = h2[i]/(p2[i]*p2[i]-dis*dis/4);
double C = -A*dis*dis/4.0;
double vy = sqrt(2*C);
double vx = dis/(2*vy);
double v = sqrt(vx*vx+vy*vy);
int flag = 1;
for(int j=1;j<=n;j++)
{
double H = A * p2[j] * p2[j] + C;
if(h2[j]-H>eps)
{
flag = 0;
break;
}
}
if(flag)
{
ans = min(ans,v);
}
} double v = sqrt(dis);
double C = dis/4;
double A = -1/dis;
int flag = 1;
for(int i=1;i<=n;i++)
{
double H = A * p2[i] * p2[i] + C;
if(h2[i]-H>eps)
{
flag = 0;
break;
}
}
if(flag)
ans = min(ans,v);
//cout<<ans<<" "<<v<<endl;
return ans;
}
int main()
{
scanf("%lf%d%d",&d,&n,&b);
b++;
for(int i=1;i<=n;i++)
scanf("%lf%lf",&p[i],&h[i]);
double v = 1e9;
for(int i=1;i<=b;i++)
v=min(v,solve(i));
printf("%.10f\n",v);
}

Codeforces Gym 100803D Space Golf 物理题的更多相关文章

  1. Codeforces GYM 100114 B. Island 水题

    B. Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description O ...

  2. Codeforces Gym 100431D Bubble Sort 水题乱搞

    原题链接:http://codeforces.com/gym/100431/attachments/download/2421/20092010-winter-petrozavodsk-camp-an ...

  3. Codeforces gym 100685 C. Cinderella 水题

    C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C ...

  4. Space Golf~物理题目

    Description You surely have never heard of this new planet surface exploration scheme, as it is bein ...

  5. Codeforces Gym 100286G Giant Screen 水题

    Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...

  6. codeforces gym 100345I Segment Transformations [想法题]

    题意简述 给定一个由A C G T四个字母组成的密码锁(每拨动一次 A变C C变G G变T T变A) 密码锁有n位 规定每次操作可以选取连续的一段拨动1~3次 问最少几次操作可以将初始状态变到末状态 ...

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

  8. Codeforces Gym 101252D&&floyd判圈算法学习笔记

    一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈 ...

  9. Codeforces gym 101343 J.Husam and the Broken Present 2【状压dp】

     2017 JUST Programming Contest 2.0 题目链接:Codeforces gym 101343 J.Husam and the Broken Present 2 J. Hu ...

随机推荐

  1. Ubuntu 升级到13.10之后出现Apache2启动失败的问题

    昨天看到Ubuntu 13.04提示有新的发行版Ubuntu 13.10了,手痒了一下,没有忍住就升级了. 结果升级完毕之后发现Apache2服务启动失败了,失败信息是: Invalid comman ...

  2. centreon load average 的含义

    下面图是centreon监控到的 load 信息 其中的 load1,load5,load15 分别说明上一分钟.最后五分钟以及最后十五分钟的系统负载均值.它们的数字当然是越小越好.数字越高,说明服务 ...

  3. 【C++】统计代码覆盖率(三)

    报告集成到jenkins才是最终目的,因此又进行了部分资料查找,得到html和xml报告集成jenkins的配置如下: 一 集成html报告 这种方式集成在你已经用gcov+lcov生成了html报告 ...

  4. 初学JavaScript(入门一)

    javaScript是世界上最流行的脚本语言   在我们的手机.电脑设备上所浏览的所有网页,以及基于HTML5手机App的交互都是通过javaScript驱动的,所以javascript是前端工作的一 ...

  5. 全方位掌握 NSIS 的操作

    NSIS 确实是一个不错的安装程序制作软件.新版本2.0a7真正实现了中文支持和支持 WinXP 的安装对话框.不过要用它实现漂亮的安装界面和完美的安装功能就必须好好的写脚本.而 NSIS 的脚本指令 ...

  6. nagios-解决监控页面上的乱码

    1. 前景 在nagios的监控页面上发现返回来的信息为乱码,如下图所示: 查看相关日志,发现正常显示汉字,如下: 2. 解决方法(以下两个步骤缺一不可) 主要原因分析如下: 在nagios服务器上发 ...

  7. CSS width:100%和width:auto的区别

    width:100%和width:auto的区别 width:auto比较聪明,如果margin已经左右占去10px的空间,那么width给的值就是580px. <style> div{ ...

  8. 《Genesis-3D开源游戏引擎--横版格斗游戏制作教程08:虚拟键盘实现》--本系列完结

    8.虚拟键盘实现 概述: 硬键盘就是物理键盘,平时敲的那种.软键盘是虚拟的键盘,不是在键盘上,而是在"屏幕"上.虚拟按键就是虚拟键盘的一部分,根据功能需求,提供部分按键效果的UI可 ...

  9. WS之cxf处理的复杂类型(Map)

    一.服务端: 1.创建接口: package cn.tdtk.ws.dao; import java.util.List;import java.util.Map; import javax.jws. ...

  10. 初识Rest、JSR、JCP、JAX-RS及Jersey

    REST:即表述性状态传递(英文:Representational State Transfer,简称REST)是一种分布式应用的架构风格,也是一种大流量分布式应用的设计方法论. JSR是Java S ...