Programming Geek
Rated 4.1/5 based on 446 reviews

TCS CodeVita 2015 Round 2 : MF Tracker

Problem : MF Tracker

Mani is a savvy investor. He is reviewing his financial investment performance. He is currently analyzing his investment into mutual funds he had made in the past. From those funds he earned a certain amount each. Coincidentally, it so happened that all the funds that Mani had invested in, had in turn invested the funds in same set of stocks. So when he exited, he exited all Mutual Funds at the same time. Mani has past statements from each Fund which tell him about the number of holdings of each stock and the value of the entire portfolio when he exited those funds.

Mani is now curious to find out what was the price of each stock across all funds when he exited. He wants to do this to find out if his decision to exit the funds based on today's price was right or wrong. Your task is to help Mani find stock prices when he exited them.

Compute stock prices up to 11 decimal places and print them up to 2 decimal places.

Let's say all funds invested in TCS, Infy and Wipro, then Mani has the following knowledge

Fund 1 -> # of shares of TCS, Infy and Wipro each and overall value of Mani's portfolio
Fund 2 -> # of shares of TCS, Infy and Wipro each and overall value of Mani's portfolio
Fund 3 -> # of shares of TCS, Infy and Wipro each and overall value of Mani's portfolio
Input Format:

First line contains a single number N which denotes two things
1. Number of stocks in each mutual fund
2. Number of funds is also same as N

Next N lines, each contain a tuple representing two things
1. The quantities of each of the N stocks in the fund, delimited by space
2. The value of the holdings in that fund

Refer Sample Input for better understanding

Output Format:

Print price of each stock, upto 2 decimal point, on one line (first one on first line, second one on second line ... Nth one on Nth line). First stock is the one that comes first in the first tuple. Second stock is the one that comes second in the first tuple. So on and so forth.

OR

Print "Unsolvable" if the values of individual stocks cannot be calculated.
Sample Input and Output

SNo.InputOutput
1
3
10 9 8 56900
7 15 9 63200
12 8 1 49500

2600.00
2100.00
1500.00
2
3
10 9 8 56900
20 18 16 113800
30 27 24 170700

Unsolvable
Note:

Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Note:

Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc
Note:

For C and C++, return type of main() function should be int.