icpc kanpur problem G

Can anyone please tell why my code is giving WA??? http://www.codechef.com/viewsolution/3099344

mostly it is due to the precision error caused due to the use of double…try and convert all numbers to integers while taking input…and not after taking input…u can see my solution to understand what im trying to convey…LINK…hope this helps…:slight_smile:

Also if u want to do it by using double…u will have to use this…mostly…

double d;
cin>>d;
int ip=d*100+.5;   //this will mostly remove the error...!!!

I think it will be more safe to use:

int ip = (int)(d * 100 + 1e-6);
2 Likes

yup…i mostly use that eps value…but after i solved the problem…i saw some solutions that used double as input and they had used 0.5 and 0.9 as an eps value…hence my statement…:slight_smile:

thanx… it helped me to solve the problem…

//