ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

Ural Championship 2010

About     Problems     Submit solution     Judge status     Standings
Contest is over

D. Humpty Dumpty

Time limit: 0.5 second
Memory limit: 64 MB
'Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.
Humpty Dumpty is an unpredictable creature. As soon as he helped Alice understand the poem about the Jabberwock, he ran away to chase borogoves. Alice met him at the d6 square, and since that time she has come to the eighth rank and become a queen, but Humpty Dumpty still hasn't been seen by anyone. As many as 100100100 days passed since their talk (or, maybe, 100100100 years—time flies very fast in the Looking-Glass world). Determine the probabilities of Humpty Dumpty being on the squares of the Looking-Glass world.
It is known that every second Humpty Dumpty moved from the square he was on to one of the adjacent squares (squares are adjacent if they share at least one vertex). The probability of Humpty Dumpty moving to a square is proportional to the number of borogoves on it.

Input

The input data are eight lines containing eight integers each. The integers are the numbers of borogoves on the squares of the Looking-Glass world. The first line describes the first rank (squares from a1 to h1) and the last line describes the last rank (squares from a8 to h8). There are at least one and at most 1000 borogoves on each square of the Looking-Glass world.

Output

Output eight lines containing eight numbers each. The numbers should be the probabilities of finding Humpty Dumpty on the squares of the Looking-Glass world. The squares must be described in the order in which they are given in the input. The numbers must be accurate to at least 10−12.

Sample

inputoutput
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
0.007 0.012 0.012 0.012 0.012 0.012 0.012 0.007
0.012 0.019 0.019 0.019 0.019 0.019 0.019 0.012
0.012 0.019 0.019 0.019 0.019 0.019 0.019 0.012
0.012 0.019 0.019 0.019 0.019 0.019 0.019 0.012
0.012 0.019 0.019 0.019 0.019 0.019 0.019 0.012
0.012 0.019 0.019 0.019 0.019 0.019 0.019 0.012
0.012 0.019 0.019 0.019 0.019 0.019 0.019 0.012
0.007 0.012 0.012 0.012 0.012 0.012 0.012 0.007

Notes

The answer in the sample is incorrect, because the numbers in it are given with insufficient accuracy.
Problem Author: Sergey Pupyrev (prepared by Eugene Krokhalev)
Problem Source: The 14th Urals Collegiate Programing Championship, April 10, 2010
To submit the solution for this problem go to the Problem set: 1766. Humpty Dumpty