UVa11646 - Athletics Track(水题)

来源:互联网 发布:node 命令行多步执行 编辑:程序博客网 时间:2024/04/29 04:31

London Olympics is approachingvery shortly – in just 3 years. Three years might not sound as that small atime 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 Olympicvillage for accommodating athletes and officials, improving the transportationof the entire city as the venues are located all over the city and also therewill be great number of tourists / spectators during the Olympics.

Text Box:                               Geometric ModelText Box:                               Actual View

 

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

 

Input
There will be at most 1000 test cases. Each test case will be given in oneline. It will contain ratio of the length and width of the rectangle in theformat – “a : b”. Here, a and b will be integers and both will be between 1 and1000 (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 lengthand width of the rectangle (in meters) respectively. You can output as manydigits as you want after the decimal point. Output will be verified by avalidator for 1E-5 precision.

               

Sample Input                           Output for SampleInput

3 : 2

5 : 4

Case 1: 117.1858168913 78.1238779275

Case 2: 107.2909560477 85.8327648381

import java.io.FileInputStream;import java.io.BufferedInputStream;import java.io.OutputStreamWriter;import java.io.PrintWriter;import java.util.Scanner;public class Main implements Runnable{private static final boolean DEBUG = false;private PrintWriter cout;private Scanner cin;private int a, b;private int cas = 1;private void init(){try {if (DEBUG) {cin = new Scanner(new BufferedInputStream(new FileInputStream("d:\\OJ\\uva_in.txt")));} else {cin = new Scanner(new BufferedInputStream(System.in));}cout = new PrintWriter(new OutputStreamWriter(System.out));} catch (Exception e) {e.printStackTrace();}}private boolean input(){if (!cin.hasNextInt()) return false;a = cin.nextInt();cin.next();b = cin.nextInt();return true;}private void solve(){double theta = Math.atan2(b, a) * 2;double x = 400 / (Math.sqrt(a * a + b * b) * theta + 2 * a);cout.print("Case " + cas++ + ": ");cout.println(x * a + " " + x * b);cout.flush();}public void run(){init();while (input()) {solve();}}public static void main(String[] args){new Thread(new Main()).start();}}



0 0
原创粉丝点击