beecrowd | 1819

Estimating Production

By Unknown BR Brazil

Timelimit: 3

China is a major producer of food, but also huge consumer. Chinese researchers discover that in certain moments of their history the agricultural production was higher than consumption, and at other times this situation was reversed. Worried with the future of the great nation, they started to collect data about the plantation area, the quantity of workers e the agricultural production. To better investing their resources , now they want to make a forecast about the production of the country.

The data set that the researchers collect is composed by triples (Xi, Yi, Zi), where Xi representes the area of plantation, Yi the quantity of workers and Zi the agriculture production. As this production is directly linked with the other data collected, they decided to estimate the future production using a linear function a1+a2x+a3y, that minimizes the sum of the square errors

where n is the total of triples availables. Thus they will be capable to better plan the production and the consume of the next years. Your goal is to calculate the desired linear function.


The input consistes of many instances. For each input instance is given one integer number 3 ≤ n ≤ 1000 indicating how much triples was obtained in the data collection. In each one of the next lines is given a triple Xi, Yi and Zi as acreage (thousand acres), the number of workers involved (given in thousands), and agricultural production (given in tonnes of food), respectively. The input file ends when n = 0 is found. Assume that there is no linear relationship between the number of workers and the acreage, then, there is no constants α,β such that, for every i, Xi= αyi + β. Assume also that 0 ≤ Xi,Yi,Zi ≤ 1000 and that all data values are integers.


For each instance solved, you may print a identifier Instance h where h is a integer number, sequential and growing from 1. On the next line, you may print 3 numbers a1, a2 and a3, representing the quotients of the requested linear function. These numbers need to be represented in three decimal places.

A blank line shoud divide the output of each instance

Sample Input Sample Output


1 0 0

5 1 1

3 2 2


1 3 2

3 7 3

5 10 4

7 400 5

9 4 6


Instancia 1

0.000 0.000 1.000

Instancia 2

1.500 0.500 0.000