Skip to content

Instantly share code, notes, and snippets.

@cocodrips
Created July 2, 2014 17:52
Show Gist options
  • Save cocodrips/f9409d78511adbd6f52d to your computer and use it in GitHub Desktop.
Save cocodrips/f9409d78511adbd6f52d to your computer and use it in GitHub Desktop.
ICPC2013予選、A問題をpythonで
def table(n):
t = []
for w in xrange(1, n + 1):
for h in xrange(1, w):
t.append((pow(h, 2) + pow(w, 2), h, w))
return sorted(t)
if __name__ == '__main__':
t = table(150)
while True:
h, w = map(int, raw_input().split())
if w == 0 and h == 0:
break
i = t.index((pow(h, 2) + pow(w, 2), h, w))
print t[i+1][1], t[i+1][2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment