Skip to content

Instantly share code, notes, and snippets.

@cocodrips
Created July 21, 2014 15:37
Show Gist options
  • Save cocodrips/9808208c4cb650dc484d to your computer and use it in GitHub Desktop.
Save cocodrips/9808208c4cb650dc484d to your computer and use it in GitHub Desktop.
SRM620 Div1 Easy なんかアリーナだとエラー出る。謎。
class PairGame:
def maxSum(self, a, b, c, d):
partA = self.parts(a, b)
partC = self.parts(c, d)
group = sorted(list(partA.items()), reverse=True)
for g in group:
if partC.has_key(g[0]):
if partC[g[0]] == g[1]:
return g[0]
return -1
def parts(self, a, b):
dict = {}
dict[a + b] = (a, b)
while a > 0 and b > 0:
if a > b:
a, b = a - b, b
else:
a, b = a, b - a
dict[a + b] = (a, b)
return dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment