UVa 11646 - Athletics Track

因为两段圆弧在同一个圆上,所以该圆是矩形的外接圆,由此可通过圆心角解得两段圆弧长,设矩形的长为x,宽为y,列出方程可解得:

x = 400.0 / ( 2.0 + ( 2.0 * atan( b / a ) * sqrt( a*a + b*b ) ) / a )

y = x * b / a;

 1 #include <cstdio>

 2 #include <cmath>

 3 #include <algorithm>

 4 

 5 using namespace std;

 6 

 7 int main()

 8 {

 9     int cas = 0;

10     double a, b;

11     while( ~scanf( "%lf : %lf", &a, &b ) )

12     {

13         double x = 400.0 / ( 2.0 + ( 2.0 * atan( b / a ) * sqrt( a*a + b*b ) ) / a );

14         double y = x * b / a;

15         printf( "Case %d: ", ++cas );

16         printf( "%.10f %.10f\n", x, y );

17     }

18     return 0;

19 }

 

你可能感兴趣的:(rack)