题目:

Description

The recreation center of WHU ACM Team has indoor billiards, Ping Pang, chess and bridge, toxophily, deluxe ballrooms KTV rooms, fishing, climbing, and so on. 
We all like toxophily.

Bob is hooked on toxophily recently. Assume that Bob is at point (0,0) and he wants to shoot the fruits on a nearby tree. He can adjust the angle to fix the trajectory. Unfortunately, he always fails at that. Can you help him?

Now given the object's coordinates, please calculate the angle between the arrow and x-axis at Bob's point. Assume that g=9.8N/m.

 

Input

The input consists of several test cases. The first line of input consists of an integer T, indicating the number of test cases. Each test case is on a separated line, and it consists three floating point numbers: x, y, v. x and y indicate the coordinate of the fruit. v is the arrow's exit speed. 
Technical Specification

1. T ≤ 100. 
2. 0 ≤ x, y, v ≤ 10000. 

 

Output

For each test case, output the smallest answer rounded to six fractional digits on a separated line. 
Output "-1", if there's no possible answer.

Please use radian as unit.

 

Sample Input

3
0.222018 23.901887 121.909183
39.096669 110.210922 20.270030
138.355025 2028.716904 25.079551
 

Sample Output

1.561582
-1
-1
 
采用数学方法,很simple~
但是WA了~错在.....很让人无语的地方......= =下次要细心点!!!!
代码:
 #include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std; const double g=9.8; int main()
{
int n;
scanf("%d",&n);
while(n--)
{
double t,s,x,y,v;
scanf("%lf%lf%lf",&x,&y,&v);
t=v*v*v*v*x*x-g*x*x*(g*x*x+*v*v*y);
if(t<)
printf("-1\n");
else
{ s=(*v*v*x-*sqrt(t))/(*g*x*x);
if(s<)
s=(*v*v*x+*sqrt(t))/(*g*x*x);
printf("%.6lf\n",atan(s));
}
}
return ;
}
 
 
 
 
 

HDU 2298 Toxophily的更多相关文章

  1. HDU 2298 Toxophily(公式/三分+二分)

    Toxophily Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  2. HDU 2298 Toxophily 【二分+三分】

    一个人站在(0,0)处射箭,箭的速度为v,问是否能够射到(x,y)处,并求最小角度. 首先需要判断在满足X=x的情况下最大高度hmax是否能够达到y,根据物理公式可得 h=vy*t-0.5*g*t*t ...

  3. HDU -2298 Toxophily(三分法)

    这道题目,可以推出物理公式直接来做,但是如果推不出来就必须用程序的一种算法来实现了,物理公式只是适合这一个或者某个题,但是这种下面这种解决问题的方法确实解决了一类问题 ----三分法,大家可能都听说过 ...

  4. HDU 2298 三分

    斜抛从(0,0)到(x,y),问其角度. 首先观察下就知道抛物线上横坐标为x的点与给定的点的距离与角度关系并不是线性的,当角度大于一定值时可能会时距离单调递减,所以先三分求个角度范围,保证其点一定在抛 ...

  5. HDU 2298:Toxophily(推公式)

    http://acm.hdu.edu.cn/showproblem.php?pid=2298 题意:给出一个x,y,v,问从(0,0)以v为初速度射箭,能否射到(x,y)这个点,如果能,输出最小的射出 ...

  6. Toxophily HDU - 2298 三分+二分

    代码+解析: 1 //题意: 2 //有一个大炮在(0,0)位置,为你可不可以把炮弹射到(x,y)这个位置 3 //题目给你炮弹初始速度,让你求能不能找出来一个炮弹射出时角度满足题意 4 //题解: ...

  7. [hdu 2298] 物理推导+二分答案

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2298 #include<bits/stdc++.h> using namespace st ...

  8. HDU 2298(纯物理加解一元二次方程)

    Toxophily Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  9. Toxophily-数论以及二分三分

    G - Toxophily Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submi ...

随机推荐

  1. 用javascript操作xml

    用javascript操作xml 可以使用标准DOM操作. IE创建XML MSXML2.0DOMDocument function createXMLDOM(){ var version = [ ' ...

  2. 面试题:实现LRUCache::Least Recently Used的缩写,意思是最近最少使用,它是一种Cache替换算法

    Design and implement a data structure for Least Recently Used (LRU) cache. It should support the fol ...

  3. Java 之 网络编程

    1.OSI模型 a.全称:开放系统互联 b.七层模型:应用层.表示层.会话层.传输层.网络层.数据链路层.物理层 c.注意:OSI模型 是所谓的 理论标准 2.TCP/IP模型 a.四层模型:应用层. ...

  4. 除了判断语句if switch 我们还可以怎么做?-b

    之前项目中有根据后台数据执行不同代码,根据不同的字符串返回不同UIViewController对象,最开始需要的vc 种类不多我用的是if else 做字符串比较再执行不同代码,但是如果需求的vc 有 ...

  5. 最浅显、易懂的Linux 硬链接与软链接的理解

    正文: Linux上的文件可以这么理解:文件-->文件名.文件是一个Object,也就是磁盘上的二进制数据.一个文件可以有多个文件名,平时我们都是通过文件名访问文件Object. 这样,硬链接可 ...

  6. 转:浅谈命令查询职责分离(CQRS)模式

    原文来自于:http://www.cnblogs.com/yangecnu/p/Introduction-CQRS.html 在常用的三层架构中,通常都是通过数据访问层来修改或者查询数据,一般修改和查 ...

  7. 【技术贴】note8 N5100刷机 双清 落雨

    双清模式:开机键 + [音量+] + HOME键 刷机模式:开机键 + [音量- ]+ HOME键 1.双清步骤: 关机时.长按音量上键+home键+开机键,直到进入recovery模式,然后选择wi ...

  8. 【HDU3374】 String Problem (最小最大表示法+KMP)

    String Problem Description Give you a string with length N, you can generate N strings by left shift ...

  9. leetcode面试准备:Contains Duplicate I && II

    1 题目 Contains Duplicate I Given an array of integers, find if the array contains any duplicates. You ...

  10. FishEye简介

    前言     在项目开发过程中,随着开发的进行,将有大量的代码编写提交到代码仓库,如何能全面准确的了解源代码的变化,提交的频率,代码量的趋势,发现代码的缺陷,将是控制源代码质量的重要指标,这个时候一个 ...