CodeForces 215B Olympic Medal(数学啊)

题目链接:http://codeforces.com/problemset/problem/215/B


Description

The World Programming Olympics Medal is a metal disk, consisting of two parts: the first part is a ring with outer radius of r1 cm, inner radius of r2 cm, (0 < r2 < r1) made of metal with density p1 g/cm3. The second part is an inner disk with radius r2 cm, it is made of metal with density p2 g/cm3. The disk is nested inside the ring.

The Olympic jury decided that r1 will take one of possible values of x1, x2, ..., xn. It is up to jury to decide which particular value r1 will take. Similarly, the Olympic jury decided that p1 will take one of possible value of y1, y2, ..., ym, and p2 will take a value from listz1, z2, ..., zk.

According to most ancient traditions the ratio between the outer ring mass mout and the inner disk mass min must equal , where A, B are constants taken from ancient books. Now, to start making medals, the jury needs to take values for r1p1p2 and calculate the suitable value of r2.

The jury wants to choose the value that would maximize radius r2. Help the jury find the sought value of r2. Value r2 doesn't have to be an integer.

Medal has a uniform thickness throughout the area, the thickness of the inner disk is the same as the thickness of the outer ring.

Input

The first input line contains an integer n and a sequence of integers x1, x2, ..., xn. The second input line contains an integer m and a sequence of integers y1, y2, ..., ym. The third input line contains an integer k and a sequence of integers z1, z2, ..., zk. The last line contains two integers A and B.

All numbers given in the input are positive and do not exceed 5000. Each of the three sequences contains distinct numbers. The numbers in the lines are separated by spaces.

Output

Print a single real number — the sought value r2 with absolute or relative error of at most 10 - 6. It is guaranteed that the solution that meets the problem requirements exists.

Sample Input

Input
3 1 2 3
1 2
3 3 2 1
1 2
Output
2.683281573000
Input
4 2 3 6 4
2 1 2
3 10 6 8
2 1
Output
2.267786838055

Hint

In the first sample the jury should choose the following values: r1 = 3p1 = 2p2 = 1.


题意:
一种奖牌由内圆和外环组成,外环的半径为r1, 密度为p1。内圆的半径为r2,密度为p2;给出一种外环和内圆的质量比(A/B)!

给出一系列的r1,p1,p2!分别从中选出r1,p1,p2;要求最大的r2是多少!

PS:

内圆和外环的高度都是一样的,公式!化简后得:

((r1^2 - r2^2)*p1)/ (r1^2*p2)  = A/B。

直接找最大的r1,p1,和最小的p2;

代码例如以下:

#include <cstdio>
#include <cmath>
int main()
{
    int n, m, k;
    double r1, r2, p1, p2;
    while(~scanf("%d",&n))
    {
        double tt;
        r1 = 0;
        for(int i = 0; i < n; i++)
        {
            scanf("%lf",&tt);
            if(tt > r1)
                r1 = tt;
        }
        scanf("%d",&m);
        p1 = 0;
        for(int i = 0; i < m; i++)
        {
            scanf("%lf",&tt);
            if(tt > p1)
                p1 = tt;
        }
        scanf("%d",&k);
        p2 = 5000+47;
        for(int i = 0; i < k; i++)
        {
            scanf("%lf",&tt);
            if(tt < p2)
                p2 = tt;
        }
        int A, B;
        scanf("%d%d",&A,&B);
        double ans = sqrt((r1*r1*p1*B)/(p1*B+p2*A));
        printf("%lf
",ans);
    }
    return 0;
}



原文地址:https://www.cnblogs.com/jzssuanfa/p/6741759.html