#000122

z-hypercake

Mr Little Z decided to make a hypercake. A hyper cake is a cake that has N ingredients, each with amount Ai for 1 <= i <= N. The cake is hypercake because some of the ingredients can have negative value, like taking "2 eggs out of the cake"


Moreover, the hypercity that Z lives in has this weird store that trades ingredients. For each ingredient Ai the store will trade it for some amounts of all the other ingredients: Bi,1, Bi,2... Bi,N of ingredients A1, A2,.... For example if N was 3 and Bi,1 = 1, Bi,2, = 1 and Bi,N = 1, and let Ai = -2. After trading that ingredient, little Z will get -2 of A1, -2 of A2 = -2, and A3 = -2.


However the hyperstores have the following policy. Each trade takes one day. So mister little Z gives the amount of some ingredient today, and picks up the traded ingredients tomorrow. Moreover, Mr Little Z has to trade the WHOLE amounts of all the ingredients that he is possessing. For example if he had Ai = -2 for all i, then he has to trade all -2 of all the ingredients


Now, mister Little Z wants to make such a recipe that if he trades all the ingredients in the store, then he will be able to make [] times more cakes tomorrow, where C is some real constants. And he wants to maximize C. Moreover, he wants NOT TO HAVE any leftover ingredients (To be more accurate he can have at most 0.001% of the leftovers, i.e. if he had Ai = 2 on the first day, then he can have at most 0.00002 of ingredient i left after making C cakes on the second day). Also, mister little Z HAS to trade ALL the ingredients or NONE!


InputFrom the first line read an integer N (1 <= N <= 50). From each of the next N lines read N integers (from [0, 1000]) representing the trading deals. Each line represents what would little Z get for the corresponding ingredient.

OutputTo the standard output write C with three decimal point precision.

Input:
[c]2
1 1
2 0

Output:
2.000

Explanation: Mister little Z can choose a recipe with A1 = 2 and A2 = 1. For trading 2 units of the first ingredient he gets 2*1 = 2 units of the first ingredient, and 1*2 units of the second. For trading the second ingredient he gets 2 units of the first ingredient and 0 of the second. So, the next day he ends up with A1 = 4 and A2 = 2, which is exactly twice as much of each ingredient, so he can make 2.000 times more cakes, with NO leftovers!
Input:
3
2 1 0
1 2 1
0 1 1

Output:
3.247

Explanation: We have A1 = -0.591009..., A2 = -0.736976..., A3 = -0.327985... and you can calculate how much of each of the ingredients he will have after trading these ones - it will be ~3.247 times more of each ingredient.

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.