Can't resolve NZEC error in Python on codechef, Although it gave correct output on IDE
Question:
def gcd(x,y):
while(x!=y):
if(y != 0):
return(gcd(y,x%y))
else:
return(x)
t = input()
while (t>0):
t = t-1
a,b,n = raw_input().split(" ")
a=int(a)
b=int(b)
n=int(n)
x = pow(a,n) + pow(b,n)
y = a-b
print(gcd(x,y))
Here i got NZEC(Runtime) error in codechef but if i write test cases mannually then it is work finely, So please Help…
Answers:
For python 3
-
Convert the t
variable to int
t=int(t)
-
Change raw_input()
to input()
.
Comment the line if you have not.
def gcd(x,y):
while(x!=y):
if(y != 0):
return(gcd(y,x%y))
else:
return(x)
t = input()
while (t>0):
t = t-1
a,b,n = raw_input().split(" ")
a=int(a)
b=int(b)
n=int(n)
x = pow(a,n) + pow(b,n)
y = a-b
print(gcd(x,y))
Here i got NZEC(Runtime) error in codechef but if i write test cases mannually then it is work finely, So please Help…
For python 3
-
Convert the
t
variable toint
t=int(t)
-
Change
raw_input()
toinput()
.
Comment the line if you have not.