Hi All,
I was trying to solve this problem , I have checked with 100 of test cases all are working fine but getting RTE when I submit it.
can't figure out what's wrong with my code.
spoj.com/problems/QUADRATE/
[bbone=python,698]import sys
def solver(a,b,c):
if(a==0):
a=1
if(b==0):
b=1
#print a,b,c
if((b*b-4*a*c) > 0):
return "Distinct real roots."
elif((b*b-4*a*c)==0):
return "Equal roots."
else:
return "Imaginary roots."
def compute(arr):
a=int(arr[0])
b=int(arr[2])
c=int(arr[4])
if(arr[1]=='-'):
b*=-1
if(arr[3]=='-'):
c*=-1
return solver(a,b,c)
def main():
t=int(sys.stdin.readline())
flag=0
m=0
n=0
x=0
op=""
for cs in xrange(t):
m=0;n=0;x=0;op="";flag=1
arr=[]
optr=[]
ans=0
s=sys.stdin.readline()
while(x < len(s)):
if(s[x]=='-' or s[x]=='+'):
op+=s[x]
flag=0
if(flag==1):
if(s[x]=='0' or s[x]=='1' or s[x]=='2' or s[x]=='3' or s[x]=='4' or s[x]=='5' or s[x]=='6' or s[x]=='7' or s[x]=='8' or s[x]=='9'):
m*=10
m+=int(s[x])
if(flag==0):
arr.append(m)
arr.append(op)
m=0
op=""
flag=1
x+=1
m/=10
arr.append(m)
#print arr
print compute(arr)
main()[/bbone]