Sicily 1526. Model Rocket Height

1526. Model Rocket Height

Constraints

Time Limit: 1 secs, Memory Limit: 32 MB

Description

Just when you thought we had run out of model rocket height problems...

Yet another method used to determine the height achieved by a model rocket is the vertical line method. Two observers A and B are spaced D feet apart along a base line along one edge of the flat test field. The launch platform is equidistant from observers A and B and L feet from the base line. Each observer has a theodolite or some other device for measuring angle above the horizontal (elevation angle) of a distant object and the azimuth angle (the angle the vertical plane of the sight line makes with the line from A through B measured counter-clockwise). Each measuring device is on a stand. A's device is HA feet above the level of the launch platform and B's device is HB feet above the level of the launch platform. When a rocket is fired, near the top of its flight, it deploys a parachute and emits a puff of smoke. Each observer measures the elevation angle and azimuth angle of the puff of smoke from their location. If the peak location is on the wrong side of the baseline or outside the lines determined by A and B perpendicular to the base line, it is out of bounds and disqualified. From this information, the height of the rocket may be determined as follows:

Each sight line determines a vertical plane. These two planes intersect in a vertical line (thus the name of the method). Each sight line intersects this vertical line in a point. If these points are more than ERRDIST feet apart, an error is assumed and the flight is rejected. Otherwise, the point halfway between the two points where a sight line intersects the vertical line is computed. The rocket height is the distance of this midpoint above the launch platform.

You must write a program which, given the parameters D (the distance in feet between observers A and B), L (the distance in feet from the base line to the launch platform), HA (the distance of the measuring device A above the launch platform in feet), HB (the distance of the measuring device B above the launch platform in feet),ERRDIST (the maximum distance between the intersection points of a sight line with the vertical line), α (the elevation angle of the rocket in degrees measured by the left observer A), β (the elevation angle of the rocket in degrees observed by the right observer B), γ  (the azimuth angle in degrees measured by the left observer A) and δ(the azimuth angle in degrees measured by the right observer B), computes the height of the rocket above the launch platform in feet to the nearest foot.

Input

The first line of input contains a single integer N , (1$ \le$N$ \le$1000) which is the number of datasets that follow.

The second line contains the parameters D , L , HA , HB and ERRDIST in that order as (floating point) decimal values. These values would be measured once at the beginning of the day and remain fixed through all rocket shots.

Each succeeding line of input represents a single dataset. Each dataset will contain the angles α , β , γ and δ in that order (measured in degrees) as (floating point) decimal values for a rocket shot.

Output

For each dataset of four angles, the output consists of a single line . If angles α , βand γ are not strictly between 0 and 90 degrees or δ is not strictly between 90 degrees and 180 degrees, the line should contain the dataset number, a space and the word ``DISQUALIFIED" (without the quotes). Otherwise, if the distance between the intersection points of a sight line with the vertical line is more thatERRDIST feet, the line should contain the dataset number, a space and the word ``ERROR" (without the quotes). Otherwise, the line should contain the dataset number, a space and the height above the launch platform in feet to the nearest foot.

Sample Input

4 
100.0 300.0 5.25 2.92 5.00 
40.1 36.2 35.3 151.6 
64.9 71.1 15.7 160.1 
44.9 41.2 33.1 152.5 
44.9 41.2 33.1 52.5

Sample Output

1 50 
2 ERROR 
3 58 
4 DISQUALIFIED

Problem Source

Greater New York 2007

// Problem#: 1526
// Submission#: 3462177
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <string.h>
#include <math.h>
#include <list>
#include <set>
using namespace std;

const double PI = 3.14159265358979323846264338327950288;

double angel2PI(double a) {
    return PI * a / 180;
}

struct treDPoint {
    double x, y, z;
    treDPoint(double xx = 0, double yy = 0, double zz = 0) {
        x = xx;
        y = yy;
        z = zz;
    }
};

bool judge(double Aea, double Bea, double Aaa, double Baa) {
    return 0 < Aea && Aea < 90 && 0 < Bea && Bea < 90 && 0 < Aaa && Aaa < 90 && 90 < Baa && Baa < 180;
}

double dis(treDPoint M, treDPoint N) {
    return sqrt((M.x - N.x) * (M.x - N.x) + (M.y - N.y) * (M.y - N.y) + (M.z - N.z) * (M.z - N.z));
}

int main() {

    //std::ios::sync_with_stdio(false);
    
    int caseNum;
    scanf("%d", &caseNum);
    int counter = 1;

    treDPoint A, B;
    double d, l, Ha, Hb, eD;

    scanf("%lf%lf%lf%lf%lf", &d, &l, &A.z, &B.z, &eD);
    A.x = -d / 2;
    B.x = d / 2;

    while (caseNum--) {
        double Aea, Bea, Aaa, Baa;
        scanf("%lf%lf%lf%lf", &Aea, &Bea, &Aaa, &Baa);
        if (!judge(Aea, Bea, Aaa, Baa)) {
            printf("%d DISQUALIFIED\n", counter);
            counter++;
            continue;
        }

        double x = (d / 2 * (tan(angel2PI(180 - Baa)) - tan(angel2PI(Aaa)))) / (tan(angel2PI(Aaa)) + tan(angel2PI(180 - Baa)));
        double y = x * tan(angel2PI(Aaa)) + d / 2 * tan(angel2PI(Aaa));
        double z = 0;
        treDPoint floorPoint(x, y, z);
        double h1 = tan(angel2PI(Aea)) * dis(floorPoint, treDPoint(A.x, A.y, 0));
        double h2 = tan(angel2PI(Bea)) * dis(floorPoint, treDPoint(B.x, A.y, 0));
        h1 += A.z;
        h2 += B.z;

        if (fabs(h1 - h2) > eD) {
            printf("%d ERROR\n", counter);
            counter++;
            continue;
        }

        printf("%d %.0lf\n", counter, (h1 + h2) / 2);
        counter++;
    }

    return 0;
}                                 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值