PCJ18C - Help Required

Please tell me where I’m going wrong.

import fractions
import string

t=input()
if t>50 or t<1:
print “Not allowed”
exit()

while t>0:
n,a,k=raw_input().split()
n,a,k=[int(n),float(a),int(k)]

if n<3 or n>1000:
    break
elif a<1.0 or a>1000000000.0:
    break
elif k<1 or k>n:
    break

ak=0.0
ak=a+(k-1)*((n-2)*(2*180)-2*a*n)/(n*(n-1))
b=fractions.Fraction(ak)
x=b.numerator
y=b.denominator
print x,y
t-=1

The given constraints are less than or equal to, not less than. You have done t < 50 while it should be t < 51 or t <= 50. And secondly, there is no need to check for these things as constraints mean there will be no such value out of the range.

1 Like