lightoj1056Olympics

来源:互联网 发布:软件批量卸载 编辑:程序博客网 时间:2024/06/07 07:54



A - Olympics
Time Limit:500MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu
Submit Status Practice LightOJ 1056

Description

The next Olympic is approaching very shortly. It's a hard job for the organizers. There are so many things to do - preparing the venues, building the Olympic village for accommodating athletes and officials, improving the transportation of the entire city as the venues are located all over the city and also there will be great number of tourists/spectators during the Olympics.

One of the most important tasks is to build the stadium. You are appointed as a programmer to help things out in certain matters - more specifically in designing and building the athletics tracks. After some study, you find out that athletics tracks have a general shape of a rectangle with two sliced circles on two ends. Now the turf that is placed inside this rectangle is prepared elsewhere and comes in different shapes - different length to width ratios. You know one thing for certain - your track should have a perimeter of 400 meters. That's the standard length for athletics tracks. You are supplied with the design parameter - length to width ratio. You are also told that the sliced circles will be such that they are part of the same circle. You have to find the length and width of the rectangle.

Input

Input starts with an integer T (≤ 1000), denoting the number of test cases.

Each case starts with the ratio of the length and width of the rectangle in the format: "a : b". Here, a and b will be integers and both will be between 1 and 1000 (inclusive).

Output

For each case, print the case number, the length and the width. Errors less than 10-6 will be ignored.

Sample Input

2

3 : 2

5 : 4

Sample Output

Case 1: 117.1858168 78.12387792

Case 2: 107.29095604 85.8327648


题意:如图给出长宽比在圆内求赛道为400米时的长和宽
虽说是一道简单题却让我做到现在,哎。
#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#define PI acos(-1.0)using namespace std;int main(){int t,k=1;double l,w,r;scanf("%d",&t);while(t--){scanf("%lf : %lf",&l,&w);r=w/l;double D=400.0/(2.0*cos(atan(r))+2.0*atan(r));printf("Case %d: %.7lf %.7lf\n",k++,D*cos(atan(r)),D*sin(atan(r)));}return 0;}


0 0
原创粉丝点击