hd2298
发布日期:2022-02-08 04:20:46 浏览次数:2 分类:技术文章

本文共 2028 字,大约阅读时间需要 6 分钟。

大哭大哭大哭大哭大哭大哭

Toxophily

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 16   Accepted Submission(s) : 7
Problem 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.<br>We all like toxophily.<br><br>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?<br><br>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. <br>
 

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.<br>Technical Specification<br><br>1. T ≤ 100.<br>2. 0 ≤ x, y, v ≤ 10000. <br>
 

Output
For each test case, output the smallest answer rounded to six fractional digits on a separated line.<br>Output "-1", if there's no possible answer.<br><br>Please use radian as unit. <br>

方法

Solution 

这里写图片描述
 

判断一下x1,x2是否在[          0       ,      pi       ]之间然后选一个合法的较小值即可 

#include
#include
#include
using namespace std;#define g 9.8#define pi acos(-1.0)/2.0int main(){ int T; double x,y,v; scanf("%d",&T); while(T--) { scanf("%lf%lf%lf",&x,&y,&v); double a=g*x*x; double b=-2.0*x*v*v; double c=2.0*y*v*v+g*x*x; double d=b*b-4.0*a*c; if(d<0) { printf("-1\n"); continue; } d=sqrt(d); double x1=atan((-b+d)/(2.0*a)),x2=atan((-b-d)/(2.0*a)); if(x1<0||x1>pi&&x2<0||x2>pi)printf("-1\n"); else if(x1<0||x1>pi)printf("%.6lf\n",x2); else if(x2<0||x2>pi)printf("%.6lf\n",x1); else printf("%.6lf\n",x1

转载地址:https://blog.csdn.net/weixin_38960774/article/details/79391968 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Can you find it?2446 csdn直达http://blog.csdn.net/jingttkx/article/details/51302721
下一篇:计祘客-八皇后问题-https://nanti.jisuanke.com/t/381

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2024年03月24日 05时36分10秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

r glm 中的p值_假设检验中的P值 2019-04-21
mysql中sql语句结构_MySQL中使用sql语句获得表结构 2019-04-21
如何增加mysql主键约束_mysql修改表时怎么添加主键约束? 2019-04-21
java选择路径窗口_Java实现选择电脑路径的方法 2019-04-21
java 图像渐变_Java基础之在窗口中绘图——渐变填充(GradientApplet 1) 2019-04-21
冒泡排序面向对象java_所谓的面向对象实现的冒泡排序 2019-04-21
proto 客户端 JAVA_Kubernetes官方java客户端之五:proto基本操作 2019-04-21
java编写roguelike_RogueLike地牢生成算法Unity实现 2019-04-21
java ajax 修改数据库数据库数据库_AJAX 自学练习 无刷新提交并修改数据库数据并显... 2019-04-21
java并发编程指南博客_Java并发编程-synchronized指南 2019-04-21
java怎么中断阻塞状态_java并发编程()阻塞方法与中断方法 2019-04-21
java zlib 位运算_位运算入门:找出一个二进制数的最右端的第一个1;计算一个二进制数中1的个数;找出数组中唯一一个出现次数为奇数的数;找出数组中唯二两个出现次数为奇数的数... 2019-04-21
java lua热更新_lua热更新学习 2019-04-21
script执行php文件_php命令行(cli)下执行PHP脚本文件的相对路径的问题解决方法... 2019-04-21
apache 2.4 php5.4_apache2.4+php5.4+my sql 5.6,网站经常无故不能访问 2019-04-21
php apc.dll下载,PHP之APC缓存详细介绍 apc模块安装 2019-04-21
html贝塞尔曲线在线,贝塞尔曲线的一些事情_html/css_WEB-ITnose 2019-04-21
Java前台显示近20天的东西_第十次课:前台首页设计及显示商品信息 2019-04-21
java开发web网站的路由设计_理解Web路由(浅谈前后端路由与前后端渲染) 2019-04-21
excel如何把顺序倒过来_在excel中怎么使文字颠倒顺序反过来显示呢? 2019-04-21