LightOj1056

题目链接:http://lightoj.com/volume_showproblem.php?problem=1056

题意:已知体育场的形状是由一个矩形+两边的两个部分组成,两边的两个部分是属于同一个圆的;并且知道体育场的周长是400米,然后知道了,矩形的长宽之比,求矩形具体的长宽为多少;

根据比例找到圆的半径和对应弧的圆心角即可;

#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N = 2010;
const double eps = 1e-6;
const double PI = acos(-1);

int main()
{
    int T, t = 1, A, B;
    double a, b, r;
    scanf("%d", &T);
    while(T--)
    {
        scanf("%d : %d", &A, &B);
        a = atan(A*1.0/B);
        b = PI - 2*a;
        r = sqrt(B*B/(2-2*cos(b)));
        double l = r*b;
        double length = 200*A/(A+l);
        double width = length*B/A;
        printf("Case %d: %.6f %.6f
", t++, length, width);
    }
    return 0;
}
View Code
原文地址:https://www.cnblogs.com/zhengguiping--9876/p/5916051.html