1004
来源:互联网 发布:qq视频播放器 mac 编辑:程序博客网 时间:2024/05/17 01:57
题意:假设鲍勃是点(0,0),可以调整角度解决轨迹。帮助鲍勃摄水果在附近的树,并给出 一个点 x ,y 坐标,给出初速度。求从坐标原点以什么角度斜上抛运动可以达到那个点。
思路:根据以前所学物理学知识,写出运动轨迹方程,即:a=x*x*(9.8/(2*v*v)) 再根据二分法求出角度
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
double PI=acos(1.0)
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
double PI=acos(1.0)
int main()
{
double x,y,v,a,b,c,t,x1,x2;
int n;
cin>>n;
cout.precision(6);
while(n--)
{
cin>>x>>y>>v;
if(x==0&&y==0)
cout<<0<<endl;
else
{
a=x*x*(9.8/(2*v*v));
b=-1*x;
c=y+a;
t=b*b-4*a*c;
if(t<0)
cout<<-1<<endl;
else
{
x1=(-1*b-sqrt(t))/(2*a);
x2=(-1*b+sqrt(t))/(2*a);
if(x1>=0)
{
if(x2>=0)
x1=min(x1,x2);
cout << fixed << atan(x1) << endl;
}
else if(x2 >=0)
cout << fixed << atan(x2) << endl;
else
cout<<-1<<endl;
}
}
}
return 0;
}
0 0
- [1004]
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- Oracle笔记(十五) 数据库备份
- Java反射的基础使用
- OpenCV学习笔记(三)—— OpenCV编程起点
- 解决Adb connection Error:远程主机强迫关闭了一个现有的连接
- Oracle笔记(十六) 数据库设计范式
- 1004
- 关于Android调用invalidate()之后不能及时调用ondraw()的解决办法
- 《Java JDK8学习笔记》读书笔记(4)
- 141. Linked List Cycle
- Maven常见错误
- 对称矩阵的缩放存储
- Flaskweb实战开发的总结(前6章)
- Navicat for oracle 提示 cannot load OCI DLL,126 193的解决方法
- C++冒泡排序