Created
July 21, 2014 15:37
-
-
Save cocodrips/9808208c4cb650dc484d to your computer and use it in GitHub Desktop.
SRM620 Div1 Easy なんかアリーナだとエラー出る。謎。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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