Problem Link:- http://www.codechef.com/JUNE13/problems/PREDICT

Difficulty: Simple

Expalnation:- Look at the sample test case and think it’s a simple maths problem where you just have to divide the money in the ration of their probability. And the formula which we will get is…

if(p<0.5)p=1-p;

Amount = (2 * (1-p) * (p *10000))-((1-p) * 10000)+10000;

Link to my code is:- http://www.codechef.com/viewsolution/2220920