入门题 UVA 11646 Athletics Track

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.

                             Geometric Model

                             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 




题意:有一个400米的跑道,你知道矩形部分的长和宽的比例,然后圆弧部分的圆心是在矩形的中心的。求出长和宽分别是多少。

思路:。。。不解释了吧。

代码:

#include<iostream>
#include<cstdio>
#include<string.h>
#include<math.h>
#include<cstring>
#include<algorithm>
using namespace std;
#define eps 1e-8
struct Point
{
	Point (double xx=0,double yy=0) : x(xx) , y(yy) { }
	double x;
	double y;
};

typedef Point Vector;
Vector operator+(Vector  v1,Vector  v2) { return Vector(v1.x+v2.x,v1.y+v2.y); }
Vector operator-(Vector  v1,Vector  v2) { return Vector(v1.x-v2.x,v1.y-v2.y); }
Vector operator*(Vector  v, double p) { return Vector(v.x*p,v.y*p); }
Vector operator/(Vector  v,double p) { return Vector(v.x/p,v.y/p); }

bool operator < (Point  a,Point  b) { return a.x < b.x || (a.x==b.x && a.y < b.y); }
int dcmp(double x) 
{
	if (fabs(x) < eps) return 0;
	return x < 0 ? -1 : 1; 
}
bool operator==(const Point & a,const Point & b) 
{
	return dcmp(a.x-b.x)==0 && dcmp(a.y-b.y)==0;
}

double Dot(Vector  A,Vector  B) { return A.x*B.x+A.y*B.y; }
double Length(Vector  A) { return sqrt(Dot(A,A)); }
double Angle(Vector A,Vector B) { return acos(Dot(A,B)/Length(A)/Length(B)); }
double Cross(Vector A,Vector B) { return A.x*B.y-A.y*B.x; }
double Area2(Point a,Point b,Point c) {  return Cross(b-a,c-a); }
Vector Rotate(Vector A,double rad) 
{
	return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
}
Vector Normal(Vector A) { double L = Length(A); return Vector(-A.y/L,A.x/L); }

//点和直线
Point GetLineIntersection(Point P,Vector v,Point Q,Vector w)
{
	Vector u = P-Q;
	double t = Cross(w,u) / Cross(v,w);
	return P+v*t;
}
double DistanceToLine(Point P,Point A,Point B) 
{
	Vector v1 = B-A , v2 = P-A;
	return fabs(Cross(v1,v2))/Length(v1);
}
double DistanceToSegment(Point P,Point A,Point B)
{
	if (A==B) return Length(P-A);
	Vector v1 = B-A , v2 = P-A , v3 = P-B;
	if (dcmp(Dot(v1,v2)) < 0) return Length(v2);
	else if (dcmp(Dot(v1,v3)) > 0) return Length(v3);
	else return fabs(Cross(v1,v2))/Length(v1);
}
Point GetLineProjection(Point P,Point A,Point B) 
{
	Vector v = B-A;
	return A+v*(Dot(v,P-A)/Dot(v,v));
}
bool SegmentProperIntersection(Point a1,Point a2,Point b1,Point b2) 
{
	double c1 = Cross(a2-a1,b1-a1) , c2 = Cross(a2-a1,b2-a1) ,
		     c3 = Cross(b2-b1,a1-b1) , c4 = Cross(b2-b1,a2-b1);
	return dcmp(c1)*dcmp(c2) < 0 && dcmp(c3)*dcmp(c4)<0;
}
bool OnSegment(Point p,Point a,Point b) {
	return dcmp(Cross(a-p,b-p))==0 && dcmp(Dot(a-p,b-p)) < 0;
}
//--------------------------------------------------------------------------------------------

int a , b;
double x;
const double PI = 4*atan(1.0);

int main()
{
	int k = 0;
	while (scanf("%d",&a)==1)
	{
		char ch;
		while (ch=getchar()) { if (ch==':') break; }
		scanf("%d",&b);
		++k;
		x = 400.0/(2+sqrt(a*a+b*b)*(PI-2*atan2(a,b))/a);
		printf("Case %d: %.10lf %.10lf\n",k,x,b*x/a);
	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值