Let's Share
Time Limit: 1 Second Memory Limit: 32768 KB
Several students graduated lately are working together in a company. Although their skills are similarly excellent, they're not equally paid. So they would like to share their earnings as long they work together. Although they agree so, how to share the money is still a problem. After a long discussion, they decide to follow the following rules:a) Everyone earns some money every day;
b) Everyone should decide an arbitrary ratio at which all his money is distributed among all people;
c) Money is distributed at the end of each day;
d) The distribution should be done by a computer so that one can hide his distribution ratio from others.
Because they are all quite busy, you're asked to write a program for them. Curious as they are, your program should be able to calculate the amount of money everyone has after many many many many days...
Input
The input contains several cases. Each case begins with two integers: n(2 <= n <= 10), the number of students, and d(1 <= d <= 1000000), the number of days. The next line has n real numbers as the income for each student every day. N lines follow. Each line contains n real numbers between 0 and 1, inclusively. The jth number of the ith row Aij means that student i will give Aij of ALL of his money to student j at the end of each day. The sum of the n numbers in a line is always 1. None of the students have any money before day 1. Input is terminated by EndOfFile.
Output
For each case, output the amount of money each student has after d days in a single line with adjacent numbers seperated by a space. Round the numbers in the output to 2 digits after decimal point.
Sample Input
2 2 1 1 0.793 0.207 0.529 0.471
Sample Output
2.73 1.27Submit
Source: ZOJ Monthly, April 2003