UVALive 6835 Space Golf(物理题)
来源:互联网 发布:lq730无法网络打印 编辑:程序博客网 时间:2024/05/16 09:51
题意:
n≤10个障碍物,一个球从起点弹到终点距离为d≤10000,反弹次数b≤15,重力g=1
不计中间过程的能量损失,问可以越过所有障碍物最小的初速度是多少?
分析:
由于反弹次数很小,我们可以考虑枚举反弹次数,由于障碍物个数也很少我们也可以枚举障碍物
假设所求的速度为v,vx=vcosθ,vy=vsinθ,根据水平时间与竖直时间相等可知,12lvx=vyg
可得l=2vxvyg=v2⋅2sinθcosθg=v2⋅sin2θg ①
对于相同的速度的情况下,θ=45度时,l取到最大值为最优,所以出射角应该≥45度
对于每个反弹次数,我们可以得到球运动的抛物线的宽度l=d/(i+1)
对于一个包含障碍物的抛物线周期,我们知道三个点(0,0),(x,hi),(l,0),其中x是所在抛物线周期的pi位置
根据抛物线两根式y=a(x−x1)(x−x2)=>y=ax(x−l),解得:a=hi/(x∗(x−l))
求导y=ax(x−l)得到抛物线的斜率方程y′=2ax−al,代入x=0得,tanθ=−al,即θ=atan(−al) ②
由①变形得,v2=lgsin2θ,再由②即可算出v2
问题解决,不要忘记特判碰到障碍物的情况
代码:
//// Created by TaoSama on 2015-12-07// Copyright (c) 2015 TaoSama. All rights reserved.////#pragma comment(linker, "/STACK:1024000000,1024000000")#include <algorithm>#include <cctype>#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <iomanip>#include <iostream>#include <map>#include <queue>#include <string>#include <set>#include <vector>using namespace std;#define pr(x) cout << #x << " = " << x << " "#define prln(x) cout << #x << " = " << x << endlconst int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;const double PI = acos(-1), EPS = 1e-8;int sgn(double x) { return x < -EPS ? -1 : x < EPS ? 0 : 1;}int d, n, b;int p[15], h[15];double solve(int b) { double l = 1.0 * d / (b + 1), maxv = 0; for(int i = 1; i <= n; ++i) { double x = fmod(p[i], l); if(sgn(x) == 0) return 1e20; //collision double a = h[i] / x / (x - l), k = -a * l; double ang = max(atan2(k, 1), PI / 4); // >= 45; maxv = max(maxv, l / sin(2 * ang)); } return maxv;}int main() {#ifdef LOCAL freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);// freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);#endif ios_base::sync_with_stdio(0); while(scanf("%d%d%d", &d, &n, &b) == 3) { for(int i = 1; i <= n; ++i) scanf("%d%d", p + i, h + i); double ans = 1e20; for(int i = 0; i <= b; ++i) ans = min(ans, solve(i)); printf("%.5f\n", sqrt(ans)); } return 0;}
0 0
- UVALive 6835 Space Golf(物理题)
- UVALive 6835 - Space Golf
- UVALive 6835 - Space Golf
- UVALive 6835 - Space Golf(简单解析几何)
- UVALive 6835Space Golf-计算几何
- Space Golf (二分答案)
- UVALive 6886 Golf Bot(FFT)
- UVALive 6886 Golf Bot (FFT)
- UVALive 6886 Golf Bot
- UVALive 6886 Golf Bot FFT
- Space Golf(抛物线求速度)
- CFgym 100803D -Space Golf
- UVALive 6886 (LA 6886) Golf Bot FFT
- 【暴力预处理+剪枝/bitset】Golf Bot UVALive
- UVALive 6886 Golf Bot 桶排+剪枝
- 2014-2015 ACM-ICPC, Asia Tokyo Regional Contest D题 Space Golf(三分)
- 【UVALive】2145 - Lost in Space(数学)
- Golf
- tomcat catalina.out 文件过大,进行切割查看
- NOSQL数据库简介
- iOS — 内存分配与分区
- 第14章8节《MonkeyRunner源码剖析》 HierarchyViewer实现原理-获取控件列表并建立控件树
- UESTC 1018 王之新学期 贪心法
- UVALive 6835 Space Golf(物理题)
- POJ 1915 Knight Moves
- 第14章9节《MonkeyRunner源码剖析》 HierarchyViewer实现原理-遍历控件树查找控件
- DIV的CSS height:100%无效的解决办法
- 【BLE】CC2541之配对与绑定
- POJ 3278 Catch That Cow
- win10 iot 支持的wifi模块
- 推荐一个代码编辑器控件 LMD SyntaxEdit
- 提笔写博客