纯几何题 --- UVA - 11646 Athletics Track

这一题题目有点坑,注意这句话:

这代表了其圆心就是矩形的中心!

然后就可以推公式:

可知: x = 200/(a+2atan(b/c)*r);

r = sqrt(a*a + b*b);

所以有AC代码如下:

#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int k = 0;
    double a, b;
    while(scanf("%lf : %lf", &a, &b)!=EOF)
    {
        k++;
        double r = sqrt(a*a + b*b)/2.0;
        double x = 200.0/(a+2*atan(b/a)*r);
        printf("Case %d: %.10lf %.10lf\n", k, a*x, b*x);
    }
}
View Code

关于atan()函数: 其返回度数!(也就是反正切值)

double atan(double x);

atan() 函数的功能是求反正切值。

反正切函数 atan() 和正切函数 tan() 的功能正好相反。tan() 是已知一个角的弧度值 x,求该角的正切值 y;而 atan() 是已知一个角的正切值 y,求该角的弧度值 x。

参数

  • x

    正切值。

返回值

正切值为 x 的角的度数,以弧度表示,区间为(-π/2, π/2)

注意:atan() 并不能确定角度所在的象限,例如求得的度数是 45°,并不能说明是第一象限的角度,还有可能是第三象限的角度。如果想进一步确定角度所在的象限,请使用 atan2()。

实例

求 1 的反正切值。

  1. /* atan example */
  2. #include <stdio.h> /* printf */
  3. #include <math.h> /* atan */
  4. #define PI 3.14159265
  5. int main ()
  6. {
  7. double param, result;
  8. param = 1.0;
  9. result = atan (param) * 180 / PI; //将弧度转换为度
  10. printf ("The arc tangent of %f is %f degrees.\n", param, result );
  11. return 0;
  12. }

运行结果:
The arc tangent of 1.000000 is 45.000000 degrees.

来源:http://c.biancheng.net/ref/atan.html

如有疑问,欢迎评论指出!

posted @ 2019-01-19 17:15  mpeter  阅读(176)  评论(0编辑  收藏  举报