Drunk in the night..

0

0 votes
Problem

HTML Generator Sample Page

Yesterday night while walking under the street lights, We saw a drunk man. He was taking random steps. But there was something unique with his steps. He would either take a step North or South or East or West as if he was walking on a rectangular grid.

After each step the drunk man selects on of the four directions and moves one step further in the selected direction. Assuming that there is a probability (given in percentage) associated for going in every direction ( East , West, North, South given by four integers E , W , N , S respectively). You have tell Abhisar what is the probability that after taking N steps the drunken man never visited a location more than once.

INPUT :
The input cantains T test cases. For each test case you will be five space separated integers , N (number of  steps taken by the drunken man), E , W , N , S (the percentage chance of selecting East , West, North or South direction respectively)

OUTPUT :
Output in a single line ,for each test case, a double value denoting the probability that after taking N steps the drunken man visited a point only once.

CONSTRAINTS :
0<T<=100
1<=N<=14
0<=E,W,N,S<=100
the sum of E,W,N,S will always be 100

Time Limit: 3
Memory Limit: 256
Source Limit:
Editor Image

?