UVa11646 - Athletics Track(水题)

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
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kgduu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值