hdu-4445 暴力枚举
来源:互联网 发布:好用的网络云盘 编辑:程序博客网 时间:2024/05/21 11:23
这个题,昨天在做训练赛的时候,和队友商量出来是暴力枚举角度,但是暴力枚举角度,自己不会枚举
比赛结束后,问了一个学长,double x1 = atan(1)*4; 这个是用来表示180度是最好的方法,还有这个题的精度也需要控制,一开始是除以10000超时,后来改为
for(x = 0; x <= x1; x += (x1 / 1000));÷1000就可以过
高中物理抛物线公式 double t = (sqrt(2*9.8*h + vy * vy) + vy) / 9.8; 记得有一个位置,往上抛cos(p) < 0 所以那个速度的函数为 -vy + gt;
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>#include <vector>#include <string>#include <map>#include <math.h>#include <stack>#define LL long longusing namespace std;const int INF = 0x3f3f3f3f;int main(){ double h,l1,r1,l2,r2,x; double vx,vy; int num; int sum ; double v[210]; while(scanf("%d",&num)&&num) { scanf("%lf%lf%lf%lf%lf",&h,&l1,&r1,&l2,&r2); for(int i = 0; i < num; i++) { scanf("%lf",&v[i]); } int ans = 0; double x1 = atan(1)*4; for(x = 0; x <= x1; x += (x1 / 1000)) { sum = 0; for(int i = 0; i < num; i++) { vy = v[i]*cos(x); vx = v[i]*sin(x); double t = (sqrt(2*9.8*h + vy * vy) + vy) / 9.8; double s = vx * t; //cout<<s<<endl; if(s >= l2 && s <= r2) { sum = 0; break; } else if(s >= l1 && s <= r1) { sum++; // cout<<"*"<<endl; } } if(sum > ans) ans = sum; } printf("%d\n",ans); } return 0;}
Crazy Tank was a famous game about ten years ago. Every child liked it. Time flies, children grow up, but the memory of happy childhood will never go.
Now you’re controlling the tank Laotu on a platform which is H meters above the ground. Laotu is so old that you can only choose a shoot angle(all the angle is available) before game start and then any adjusting is not allowed. You need to launch N cannonballs and you know that the i-th cannonball’s initial speed is Vi.
On the right side of Laotu There is an enemy tank on the ground with coordination(L1, R1) and a friendly tank with coordination(L2, R2). A cannonball is considered hitting enemy tank if it lands on the ground betweenL1,R1 (two ends are included). As the same reason, it will be considered hitting friendly tank if it lands between L2,R2 . Laotu's horizontal coordination is 0.
The goal of the game is to maximize the number of cannonballs which hit the enemy tank under the condition that no cannonball hits friendly tank.
The g equals to 9.8.
Now you’re controlling the tank Laotu on a platform which is H meters above the ground. Laotu is so old that you can only choose a shoot angle(all the angle is available) before game start and then any adjusting is not allowed. You need to launch N cannonballs and you know that the i-th cannonball’s initial speed is Vi.
On the right side of Laotu There is an enemy tank on the ground with coordination(L1, R1) and a friendly tank with coordination(L2, R2). A cannonball is considered hitting enemy tank if it lands on the ground between
The goal of the game is to maximize the number of cannonballs which hit the enemy tank under the condition that no cannonball hits friendly tank.
The g equals to 9.8.
Each test case contains 3 lines.
The first line contains an integer N(0≤N≤200), indicating the number of cannonballs to be launched.
The second line contains 5 float number H(1≤H≤100000), L1, R1(0<L1<R1<100000) and L2, R2(0<L2<R2<100000). Indicating the height of the platform, the enemy tank coordinate and the friendly tank coordinate. Two tanks may overlap.
The third line contains N float number. The i-th number indicates the initial speed of i-th cannonball.
The input ends with N=0.
210 10 15 30 3510.020.0210 35 40 2 3010.020.00
10
阅读全文
0 0
- hdu 4445 暴力枚举
- hdu-4445 暴力枚举
- hdu 4445 Crazy Tank (暴力枚举)
- HDU 4445 - Crazy Tank(暴力枚举)
- hdu 3332 暴力枚举
- HDU 3823 暴力枚举
- hdu 3720 暴力枚举
- hdu 5024 暴力枚举
- HDU 4007 暴力枚举
- hdu 5128 暴力枚举
- hdu 5228 暴力枚举
- hdu 5339 暴力枚举
- HDU 5610 暴力枚举
- hdu 5660 暴力枚举
- HDU-1015/暴力枚举
- hdu 5143 暴力枚举
- HDU 1172 暴力枚举
- HDU-5578-暴力枚举
- MyCnCart之商品选项功能
- 关于表单form元素中onsubmit事件处理机制的认识
- 新手小白如何在window把自己的项目上传到github
- MAC下MYSQL5.7.17无法连接的问题
- MyCnCart之评论功能
- hdu-4445 暴力枚举
- Androidstudio好的网站
- 二:redis3.x-cluster集群于spring整合
- 学习Git需要清楚的几个术语以及常用的Git命令总结
- 【079】利用“剪叶子”算法实现树形结构的搜索功能,用Vue.js实现
- react dva 碎片01
- oracle中rownum详解
- hdu-4451 思维题
- Linux下安装mysql