Captain Hammer-google

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. V is 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/s 2  down.

Input

The first line of the input gives the number of test cases, TT 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 
 

Output 
 
3
98 980
98 490
299 1234
Case #1: 45.0000000
Case #2: 15.0000000
Case #3: 3.8870928 

推荐指数:※※

来源:google

这道题要用到一些物理上抛物线的知识。

注意asin(x)中的取值范围要在[-1.1]之间。

#include<stdio.h>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<math.h>
using namespace std;
float  cal_ang(int v,int d){
	double tmp=(9.8*d)/(v*v);
	if(fabs(tmp-1.000000)<1.0e-6){
		tmp=1.000000;
	}
	double res=asin(tmp);
	double pi=acos(-1.0);
	res=res*180/pi;
	return res;
}
int main()
{
	freopen("a.in", "r", stdin);
   freopen("a.out", "w", stdout);
	int T;
	int M;
	int caseid = 0;
	scanf("%d",&T);
	for(caseid=1;caseid<=T;caseid++){
		int v, d;
		scanf("%d%d",&v,&d);
		double res=cal_ang(v,d);
		res=res/2;
		printf("Case #%d: %.7f\n",caseid,res);
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值