CSU oj 2092-Space Golf
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 rover-type 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 energy-consuming. 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.
Figure D.1. A sample situation
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.
We will describe here the velocity of the bullet v with its horizontal and vertical components vx and vy (positive meaning upward). The initial velocity has the components vix and viy, that is, immediately after the launch of the bullet, vx = vix and vy = viy hold. We denote the horizontal distance of the bullet from the launcher as x and its altitude as y at time t.
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.
x=vixt(1)(1)x=vixt
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.
dvydt=−g(2)(2)dvydt=−g
Solving this with the initial conditions of vy = viy and y = 0 when t = 0, we obtain the following.
y==−12gt2+viyt−(12gt−viy)t(3)(4)(3)y=−12gt2+viyt(4)=−(12gt−viy)t
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 escribes the parabolic trajectory of the bullet.
y=−(g2v2ix)x2+(viyvix)x(5)(5)y=−(g2vix2)x2+(viyvix)x
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.
Input
The input consists of several tests case with the following format.
d n bp1 h1p2 h2⋮pn hnd n bp1 h1p2 h2⋮pn hn
For each test, 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.
Output
Output the smallest possible initial speed vi that makes the bullet reach the target. The initial speed vi of the bullet is defined as follows.
vi=v2ix+v2iy−−−−−−−√vi=vix2+viy2
The output should not contain an error greater than 0.0001.
Sample Input
100 1 0
50 100
10 1 0
4 2
100 4 3
20 10
30 10
40 10
50 10
343 3 2
56 42
190 27
286 34
Sample Output
14.57738
3.16228
7.78175
11.08710
题意:就是一颗子弹,由一定初速度射出(不考虑空气阻力),使其能够越过给的每一个障碍物,并且在给定次数范围内,出速度熟读最小;题解:这题我们可以暴力枚举每一个K(敲击地板的次数),其实我们可以用L/K,将区间平移,转移到一个区间里面,这里判断一下在每一个落地的地方有没有障碍物,有的话就不满足题意了,忽略即可;对于每个满足的K,我们用题中给的公式;将Vy^2表示出来,根据关系,求出Vx^2,不断维护Vx^2+Vy^2的最大值;
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
#define EXP 0.00000001
#define INF 1e17
struct node{
double p,h;
} c[11];
double Dou_mod(double a,double b)
{
if (a<b) return a;
int t=floor(a/b);
return (a-b*t);
}
int main()
{
int n,b,d;
double ans;
while(cin>>d>>n>>b)
{
for(int i=0;i<n;i++)
cin>>c[i].p>>c[i].h;
double maxx,minn=INF,vx2,vy2;
for(int i=0;i<=b;i++)
{
maxx=0;
double x0=(d*1.0)/(i+1.0);
bool yep=1;
for(int j=0;j<n;j++)
{
double p=Dou_mod(c[j].p,x0);
double h=c[j].h;
if (fabs(p-0)<EXP) { yep=0;break; }
maxx=max(maxx,x0*x0*h/(2.0*p*(x0-p)));
}
if (!yep) continue;
vy2=maxx;
vx2=x0*x0/(4.0*vy2);
if (vx2>vy2) vx2=vy2=x0/2.0;
minn=min(vy2+vx2,minn);
}
ans=sqrt(minn);
printf("%.5lf\n",ans);
}
}
CSU oj 2092-Space Golf的更多相关文章
- Codeforces Gym 100803D Space Golf 物理题
Space Golf 题目连接: http://codeforces.com/gym/100803/attachments Description You surely have never hear ...
- csu oj 1344: Special Judge
Description Given a positive integer n, find two non-negative integers a, b such that a2 + b2 = n. I ...
- csu oj 1339: 最后一滴血
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1339 1339: 最后一滴血 Time Limit: 1 Sec Memory Limit: 1 ...
- csu oj 1330 字符识别?
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1330 1330: 字符识别? Time Limit: 1 Sec Memory Limit: 1 ...
- csu oj 1811: Tree Intersection (启发式合并)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1811 给你一棵树,每个节点有一个颜色.问删除一条边形成两棵子树,两棵子树有多少种颜色是有 ...
- csu oj 1804: 有向无环图 (dfs回溯)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1804 中文题意就不说了. dfs从底到根回溯即可,看代码应该能清楚. //#pragma ...
- Space Golf~物理题目
Description You surely have never heard of this new planet surface exploration scheme, as it is bein ...
- csu oj 1343 Long Long
Description 现在有两个单调递增序列,第一个序列有N个整数,第二个序列有M个整数,现在你可以从第一个序列中选一个数x,然后从第二个序列中选一个数y,那么有多少种情况满足x+y<=K呢? ...
- csu oj 1341 string and arrays
Description 有一个N*N的字符矩阵,从上到下依次记为第1行,第2行,……,第N行,从左至右依次记为第1列,第2列,……,第N列. 对于这个矩阵会进行一系列操作,但这些操作只有两类: (1) ...
随机推荐
- docker初解
1 什么是容器 容器就是在隔离的环境中运行的一个进程,如果进程停止,容器就会退出. 隔离的环境拥有自己的系统文件,ip地址,主机名等 容器是一种软件打包技术 程序:代码,命令进程:正在运行的程序容器的 ...
- lqb 基础练习 闰年判断
基础练习 闰年判断 时间限制:1.0s 内存限制:256.0MB 问题描述 给定一个年份,判断这一年是不是闰年. 当以下情况之一满足时,这一年是闰年: 1. 年份是4的倍数而不是100的倍 ...
- nyoj 833-取石子(七) (摆成一圈,取相邻)
833-取石子(七) 内存限制:64MB 时间限制:1000ms 特判: No 通过数:16 提交数:32 难度:1 题目描述: Yougth和Hrdv玩一个游戏,拿出n个石子摆成一圈,Yougth和 ...
- 网络权重初始化方法总结(下):Lecun、Xavier与He Kaiming
目录 权重初始化最佳实践 期望与方差的相关性质 全连接层方差分析 tanh下的初始化方法 Lecun 1998 Xavier 2010 ReLU/PReLU下的初始化方法 He 2015 for Re ...
- 装饰者模式学习:模拟咖啡馆的点单系统来剖析装饰者模式的使用 + 装饰者模式在java I/O 中的应用
通过模拟咖啡馆的点单系统来剖析装饰者模式的使用 参考:https://blog.csdn.net/gududedabai/article/details/81989196 一).传统的点单系统构建,每 ...
- vux组件的样式变量的使用
使用x-header,查看文档发现有个样式变量,可以改变x-header的样式 这玩意怎么用呢? 1.在项目中创建一个.less样式文件,例如我这里是创建一个src/style/vux_theme.l ...
- GeoServer CQL查询时中文问题
1.GeoServer可以进行CQL与ECQL过滤,wms和wfs都可以 2.CQL与ECQL查询时,当传中文时会报错.将中文转为Unicode编码后就可以 /* *js Unicode编码转换 */ ...
- 20191010-7 alpha week 1/2 Scrum立会报告+燃尽图 05
此作业要求参见:https://edu.cnblogs.com/campus/nenu/2019fall/homework/8750 一.小组情况 队名:扛把子 组长:迟俊文 组员:宋晓丽 梁梦瑶 韩 ...
- Java学习笔记 线程池使用及详解
有点笨,参考了好几篇大佬们写的文章才整理出来的笔记.... 字面意思上解释,线程池就是装有线程的池,我们可以把要执行的多线程交给线程池来处理,和连接池的概念一样,通过维护一定数量的线程池来达到多个线程 ...
- CSS中选择器优先级与!important权重使用
CSS中的选择器优先级与!important权重使用 .class选择器要高于标签选择器. #id选择器要高于.class选择器. 标签选择器是优先级最低的选择器. !important的属性它的权重 ...