24h購物| | PChome| 登入
2013-05-14 09:55:15| 人氣464| 回應0 | 上一篇 | 下一篇

[UVA][二分] 11646 - Athletics Track

推薦 0 收藏 0 轉貼0 訂閱站台

A

Athletics Track

Input: Standard Input

Output: Standard Output

 

London Olympics is approaching very shortly – in just 3 years. Three years might not sound as that small a time to say ‘just’, but it is indeed for those who have to organize the competition. 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.

Text Box:                               Geometric ModelText Box:                               Actual View

 

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
There will be at most 1000 test cases. Each test case will be given in one line. It will contain 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 test case, output a line in the following format – “Case n: L W” where n is the case no (starting from 1) and L and W are length and width of the rectangle (in meters) respectively. You can output as many digits as you want after the decimal point. Output will be verified by a validator for 1E-5 precision.

                

Sample Input                           Output for Sample Input

3 : 2

5 : 4

Case 1: 117.1858168913 78.1238779275

Case 2: 107.2909560477 85.8327648381


Problem setter: Sabbir Yousuf Sanny, Special Thanks: Manzurur Rahman Khan



題目給定矩形的長跟寬比例,然後也說這矩形的四個角在圓上(即是圓的內接矩形。)
並且要求彎曲跑道總長(2*arc)+直線跑道總長(2*length) = 400 m

我們決定二分半徑 R,然後決定之。

#include <stdio.h>
#include <math.h>
int main() {
    int cases = 0;
    double a, b;
    const double pi = acos(-1);
    while(scanf("%lf : %lf", &a, &b) == 2) {
        printf("Case %d: ", ++cases);
        double l = 0, r = 1000, R;
        int cnt = 0;
        double theta = atan2(a, b), length, width, arc;
        while(l <= r && cnt < 50) {
            R = (l+r)/2;
            length = R*sin(theta)*2;
            width = R*cos(theta)*2;
            arc = R*(pi - 2*theta)*2;
            if(arc + 2*length > 400)
                r = R;
            else
                l = R;
            cnt++;
        }
        printf("%.10lf %.10lf\n", length, width);
    }
    return 0;
}

台長: Morris
人氣(464) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][二分答案+二分匹配] 11262 - Weird Fence
此分類上一篇:[UVA][二分] 10668 - Expanding Rods

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文