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.
# Enter your code here. Read input from STDIN. Print output to STDOUTimportsysdefgcd(x,y):ify==0:returnxelse:returngcd(y,x%y)defprob(a,b,c):ifa+b<=c:return1,1ifa>=candb>=c:x=c*cy=2*a*bd=gcd(x,y)returnx/d,y/difa<=candb<=c:x=2*a*b-(a-c+b)**2y=2*a*bd=gcd(x,y)returnx/d,y/da,b=max(a,b),min(a,b)x=c**2-(c-b)**2y=2*a*bd=gcd(x,y)returnx/d,y/dn=int(raw_input().strip())foriinrange(n):a,b,c,=map(int,raw_input().strip().split())x,y=prob(a,b,c)print"{}/{}".format(x,y)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Random number generator
You are viewing a single comment's thread. Return to all comments →
long but easy to understand