 # SEBIHWY_PROB

t=int(raw_input())
while t:
S,SG,FG,D,T=map(int,raw_input().strip().split(’ '))
dis=D/20.0
T=T/3600.0
speed=dis/T+S
g1=0
g2=0
g1=abs(SG-speed)
g2=abs(FG-speed)
if(g1<g2):
print ‘SEBI’
elif(g1>g2):
print ‘FATHER’
else:
print ‘DRAW’
t-=1

The probable reason could be you are printing ‘sebi’ instead SEBI…try to change it and submit…

IMP: While asking a doubt about a problem, its always better to provide the problem link and solution link rather than just copy-pasting the whole code here.

Solution (WA): https://www.codechef.com/viewsolution/14393074

Your code fails in the following testcase.

``````1
0 160 200 3 3
``````

Correct Output:-

``````DRAW
``````

``````SEBI
``````

You are facing precision error while using floating point.

A trivial example of this is:-

``````0.1 + 0.2 = 30000000000000004
``````

In the above case, correct speed = 180 whereas, your code gives speed = 179.99999999999997 and hence prints 'SEBI instead of ‘DRAW’.

This is because you are dividing one float variable with other float variable and the intermediate result cannot be stored precisely in a floating point.

If you change this

`````` dis = D / 20.0
T = T / 3600.0
speed = dis / T + S
``````

to this

``````speed = D * 180.0 / T
``````

then you should get an AC.

As a general rule, try to avoid intermediate floating point division as mush as possible.