eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Contraband

Contraband

Лимит времени 1 секунда
Лимит использования памяти 64 MiB

Было сообщено, что что-то выпало из самолета на подлете к аэропорту у залива. Скорее всего объектом была контрабанда, которая должна была быть подобраной сообщником. Полиция хочет посмотреть повтор подлета каждого самолета к аэропорту в надежде увидеть тот, который вез контрабанду. Три наблюдательные станции с оборудованием ночного видения были размещены вокруг залива (см. рисунок ниже).

Станция 1 расположена на 3.715 километров восточнее и 1.765 километров севернее станции 0, а станция 2 расположена на 2.894 километров восточнее и 2.115 километров южнее станции 0.

When a suspect aircraft crosses the bay, each observer follows it with the night vision equipment wile in contact with the other. In ane observer sees something falling from the aircraft, each records a direction to the object and aconfidence level for thet direction. The confidence level (CL) is a value from 0 (more or less pointing at the aircraft) to 1 (pointing at the splash where the object hit the water).

In general, the three sight lines will not cross at a single point but will form a triangle (See Intersection Detalabove). The best estimate of the actual position is to be the point (x, y) which minimizes the sum of the squares of the dastances d[i], to each line, weighted by the confidence level, CL[i] + 0.2,

Minimize SUM(i = 0 to 2) {(CL[i] + 0.2) * d[i]^2}

For thes problem, you will write a program which fakes as input the three observer directions and the three confidnce levels and outputs the point (x, y), which minimizes the above sum, where x is the dastance in kilometers east of station 0 and y is the distance in kilometers north (positive) or south (negative) of station 0.

Входные данные

The first line contains the number of data sets p (1 p 1000) that follow. Each data set should be processed identically and independently.

Each data set is a single line consisting of the data set number n, followed by a space, and six space separated floating point values. The floating point values are, in order a[0], CL[0], a[1], CL[1], a[2], CL[2]. a[i] is the bearing (in degrees clockwise from north) from station i (0 a[i] 360) and CL[i] is the confidence level of observer i (0 CL[i] 1).

Выходные данные

For each data set there is one line of output. It contains the data set number, N, followed by a single space witch is then followed by two space separated values x and y. x is the distance east of station 0 in kilometers, and y is the distance north (positive) or south (negative) of station 0. The distances should be displayed to 3 decimal places.

Пример

Входные данные #1
3
1 44.0 0.38 272.9 0.41 345.5 0.64
2 43.5 0.80 263.6 0.81 338.2 0.83
3 45.9 0.50 279.2 0.78 348.7 0.81
Выходные данные #1
1 1.847 1.877
2 1.440 1.511
3 2.073 2.021
Источник 2013 ACM Greater New York Region, Октябрь 27, Задача I