RANDB(LoC JUNE18) : WA for large Test cases

I have typecast every variables as either long long(int) or double(float), but still getting Wrong Answer for Large testcases 1 and 3. I am not able to figure out the mistake in the code. Please help me correct my program. My code’s link is: https://www.codechef.com/viewsolution/19062910