Google 2014校招测试赛 Problem B

Problem B. Captain Hammer

Problem

The Hamjet is a true marvel of aircraft engineering. It is a jet airplane with a single engine so powerful that it burns all of its fuel instantly during takeoff. The Hamjet doesn't have any wings because who needs them when the fuselage is made of a special Wonderflonium isotope that makes it impervious to harm.

Piloting the Hamjet is a not a job for your typical, meek-bodied superhero. That's why the Hamjet belongs to Captain Hammer, who is himself impervious to harm. The G-forces that the pilot endures when taking a trip in the Hamjet are legen-dary.

The Hamjet takes off at an angle of θ degrees up and a speed of V meters per second. Vis a fixed value that is determined by the awesome power of the Hamjet engine and the capacity of its fuel tank. The destination is D meters away. Your job is to program the Hamjet's computer to calculate θ given V and D.

Fortunately, the Hamjet's Wondeflonium hull is impervious to air friction. Even more fortunately, the Hamjet doesn't fly too far or too high, so you can assume that the Earth is flat, and that the acceleration due to gravity is a constant 9.8 m/s2 down.

Input

The first line of the input gives the number of test cases, T. T lines follow. Each line will contain two positive integers -- V and D.

Output

For each test case, output one line containing "Case #x: θ", where x is the case number (starting from 1) and θ is in degrees up from the the horizontal. If there are several possible answers, output the smallest positive one.

An answer will be considered correct if it is within 10-6 of the exact answer, in absolute or relative error. See the FAQ for an explanation of what that means, and what formats of floating-point numbers we accept.

Limits

1 ≤ T ≤ 4500; 1 ≤ V ≤ 300; 1 ≤ D ≤ 10000; It is guaranteed that each test case will be solvable.

Sample

Input 

3
98 980
98 490
299 1234

Output 

Case #1: 45.0000000
Case #2: 15.0000000
Case #3: 3.8870928

解法:抛物线已知重力,初速度和距离,求角度。算算公式就行,在精度的问题上碰了钉子。同样的公式用Python和Java得出的结果差0.0000001。重算公式,单步调试,最后还是无法解决。最后直接提交竟然通过了。幸亏没超过要求的精度范围。关键代码如下:

void run() {
    double g = 9.8;
    int COUNT = sc.nextInt();
    for (int c = 0; c < COUNT; c++) {
        double v = sc.nextInt();
        double d = sc.nextInt();
        double x = 0.25 - (d * d * g * g) / (4.0 * v * v * v * v);
        if(x<0&&x>-0.0000000001)
            x = 0;
        x = Math.sqrt(0.5 - Math.sqrt(x));
        double sin = Math.asin(x) * 180 / Math.PI;
        System.out.println(String.format("Case #%d: %.8f", c + 1, sin));
    }
}
时间: 2024-07-29 07:30:35

Google 2014校招测试赛 Problem B的相关文章

Google 2014校招测试赛 Problem A

Problem A. Bad Horse Problem As the leader of the Evil League of Evil, Bad Horse has a lot of problems to deal with. Most recently, there have been far too many arguments and far too much backstabbing in the League, so much so that Bad Horse has deci

Google 2014年全年收入是660亿,同比增长 19%

摘要: Google 刚刚发布了 2014 Q4 季度的财报:Google 2014年 全年收入是660亿,同比增长 19%.而就第四季度来说,他们收入为181亿.除了公布数据之外,Google CFO Patrick Pichette 还简要提到了那些没有 Google 刚刚发布了 2014 Q4 季度的财报:Google 2014年 全年收入是660亿,同比增长 19%.而就第四季度来说,他们收入为181亿.除了公布数据之外,Google CFO Patrick Pichette 还简要提到

利用“GOOGLE抓取”测试Robots书写正确性

中介交易 http://www.aliyun.com/zixun/aggregation/6858.html">SEO诊断 淘宝客 云主机 技术大厅 利用GOOGLE管理员工具测试Robots.TXT 与 页面内容抓取,GOOGLE管理员可以说是网站与GOOGLE间接沟通的工具,虽然G.cn现在已经移民.导致使用GOOGLE时会经常出现搜索错误或超时问题,但是GOOGLE目前所发布出来的工具无不是最权威的工具(Google Analytics .Google Trends.Google a

IT设备“零故障”亚运测试赛谢幕

近日,广州国际体育演艺中心篮球测试赛结束.同方电脑作为广州亚运会计算机设备.计算机设备运营维护和安全保障服务供应商提供商,其委派的IT工程师们在比赛开始前就分批进入赛场,安装.调试工作.测试赛从始至终,同方所提供的计算机运行稳定.高效且安全,以"零故障"的优异成绩,获得各方面认可和青睐. 清华同方将为亚运管理系统.赛果系统.计时记分系统.新闻中心等几大信息模块,以及机场.票务中心.物流中心等相关场所,提供品质过硬的计算机产品及全天候的服务保障.换玲

I.MX6 2014 u-boot 测试修改

/************************************************************************* * I.MX6 2014 u-boot 测试修改 * 说明: * 为了能够测试是否Parallel LCD在u-boot这个版本上的是否可行,做了如下 * 修改. * * 2016-8-26 深圳 南山平山村 曾剑锋 ******************************************************************

#Google I/O 2014# Google收购应用测试平台Appurify

摘要: 在刚刚进行的Google I/O大会上,Google宣布收购应用测试平台Appurify,为开发者提供App测试服务.Appurify是一家成立于2012年的公司,总部在旧金山,累计已经获得了630万美元的融资,投资方 在刚刚进行的Google I/O大会上,Google宣布收购应用测试平台Appurify,为开发者提供App测试服务.Appurify是一家成立于2012年的公司,总部在旧金山,累计已经获得了630万美元的融资,投资方里就有Google.刚刚他们在官方博客中更新了声明,宣

Google AdSense国内测试电子银行转账付款

中介交易 http://www.aliyun.com/zixun/aggregation/6858.html">SEO诊断淘宝客 站长团购 云主机 技术大厅 站长网admin5.com3月19日消息,据网友透露,目前Google AdSense已经在国内测试电子银行转账支付服务,目前只在小部分用户种进行测试.取得测试资格的用户将可以直接通过银行账户收取9001.html">人民币. 采用人民币支付方式后,用户将无需等待账户达到100美元(约680人民币)申请支付,Googl

event对象获取方法总结在google浏览器下测试_javascript技巧

简介: Event 对象代表事件的状态,比如事件在其中发生的元素.键盘按键的状态.鼠标的位置.鼠标按钮的状态. 事件通常与函数结合使用,函数不会在事件发生前被执行! Event对象的获取方法: 方法一: 例如: 复制代码 代码如下: function demo1(e){ var e = e || window.event; //此种方法在ie中和google中可以不传参数e也可以获取到event,但是在火狐中必须在事件方法中传递event参数 //才可以获取到event对象. } <input

Patrick Copeland:Google如何进行测试 之二

在对Patrick Copeland的采访的第二部分,我们主要讨论了管理一个全球开发团队的挑战:食物刺激对程序员的作用:好的测试工程师和超nb测试工程师之间的区别:以及为何某些公司始终无法提供靠谱的软件. 问:管理一个跨越一打以上国家的团队有什么挑战?在这样的团队中管理人员.流程.产品有什么样的困难?还有,你一般几点睡觉? 答:"确保对人员的掌控"<谈到这个时他脸上挂着邪恶的微笑>不是Google的解决方案.实际上,我们的团队结构在业界是非典型的.首先,我们是扁平化架构,即