HDU 4445 Crazy Tank 高中物理知识忘得差不多了
2024-09-06 20:33:32
题意不难理解,仔细看题吧,就不说题意了
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std; const double PI=acos(-1.0);
const double g=9.8; double V[205]; int main()
{
//freopen("in.txt","r",stdin);
int n;
while(scanf("%d",&n),n)
{
double H,L1,R1,L2,R2;
memset(V,0,sizeof(V));
scanf("%lf%lf%lf%lf%lf",&H,&L1,&R1,&L2,&R2);
for(int i=0; i<n; i++)
scanf("%lf",&V[i]);
if(L2<=L1 && R2>=R1)
printf("0\n");
else
{
int ans=0;
double add=PI/1000; //一开始我是另add=0.001,虽然比PI/1000还小,然而无限wa。可能是样例所要求弧度是PI平均分割的,0.001精读比PI/1000小,例如(没验证),0.003不能打到敌方,而0.00314159....可以,但是0.004也不能打到敌方。
for(double i=-PI/2; i<PI/2; i+=add)
{
int cou=0;
for(int j=0;j<n;j++)
{
double Vx0=V[j]*cos(i);
double Vy0=V[j]*sin(i);
double Vy=sqrt(2*g*H+Vy0*Vy0);
double t=(Vy-Vy0)/g;
double x=Vx0*t;
if(x>=L2 && x<=R2)
{
cou=0;
break;
}
if(x>=L1 && x<=R1)
cou++;
}
ans=ans>cou? ans:cou;
}
printf("%d\n",ans);
}
}
return 0;
}
最新文章
- Android仿“守望先锋”加载动画
- 最新版CocoaPods的使用与安装-以导入ReactiveCocoa框架为例
- ERROR 1130 (HY000) Host ‘hostname’ is not allowed to connect to this MySQL server
- 无废话ExtJs 入门教程十一[下拉列表:Combobox]
- Windows上一步一步CoreRun
- Java基础之创建窗口——使用流布局管理器(TryFlowLayout)
- Python 基础教程中的问题及解决方案(1)
- Schedule Problem spfa 差分约束
- Kotlin 类和对象
- 【洛谷P4145】花神游历各国
- jstat命令详解
- 指向字符串的指针和char类型的数组
- python binascii模块详解
- Python 爬虫-BeautifulSoup
- Drupal的目录结构
- linux下如何退出tmux和重新进入tmux
- Java Float类型 减法运算时精度丢失问题
- Laravel之Ueditor
- unity, water cube
- shell进阶教程