Last active
June 9, 2016 13:51
-
-
Save hiterm/37f1c38671308cd0bc31fdec9c1d5a9b to your computer and use it in GitHub Desktop.
http://togetter.com/li/875421 の解答(Python3)
This file contains 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
import math | |
n = int(input()) | |
n2 = n * 2 | |
max = math.floor(math.sqrt(n2)) | |
arr = [] | |
for i in range(2, max + 1): | |
if n2 % i == 0: | |
j = n2 // i | |
if i % 2 == 0 and j % 2 == 1: | |
arr.append((j + 1) // 2 - i // 2) | |
if i % 2 == 1 and j % 2 == 0: | |
arr.append(j // 2 - i // 2) | |
print(sum(arr)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment