给你一个矩形的长宽比,中间为矩形两端为圆弧的跑道周长为400,求长宽。
我的做法:
反正两边的圆弧可以随便做,那么为了方便起见,就直接用长宽的一半做直角三角形的斜长做圆弧的半径
求出周长的缩小比例
我的代码:
#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int i=0;
double r,k,a,b;
while(scanf("%lf : %lf",&a,&b)!=EOF)
{
r=sqrt(a*a+b*b)/2;
k=200/(2*r*atan(b/a)+a);
printf("Case %d: %.5lf %.5lf\n",++i,k*a,k*b);
}
}
原题:
Time limit: 1.000 seconds
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.
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 |