We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importmathr,a,b,n=map(int,input().split())count=0#function length_sq() for returning square of the sidedeflength_sq(tuple,list):len=(((list[0]-tuple[0])**2)+((list[1]-tuple[1])**2))returnlen#Coordinates of Point AA=(a/b,a/b)#C-ordinates of point BB=((2*n-(a/b)),2*n-(a/b))#length of ABAB2=length_sq(A,B)AB=math.sqrt(AB2)foriinrange(-r,r+1):forjinrange(-r,r+1):if(abs(i)+abs(j)<=r):#length of BCBC2=length_sq(B,(i,j))BC=math.sqrt(BC2)#length of ACAC2=length_sq(A,(i,j))AC=math.sqrt(AC2)try:alpha=math.acos((AB2+AC2-BC2)/(2*AB*AC))alpha=(alpha*180)/math.pialpha=round(alpha,0)beta=math.acos((AB2+BC2-AC2)/(2*AB*BC))beta=(beta*180)/math.pibeta=round(beta,0)gamma=math.acos((BC2+AC2-AB2)/(2*BC*AC))gamma=(gamma*180)/math.pigamma=round(gamma,0)if((180>alpha>90)or(90<beta<180)or(90<gamma<180)):count=count+1exceptZeroDivisionError:continueexceptValueError:continueprint(count)
All the test cases other than the first 4 gives time exceeded.
what changes should i make?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #210: Obtuse Angled Triangles
You are viewing a single comment's thread. Return to all comments →
All the test cases other than the first 4 gives time exceeded.
what changes should i make?