結果

問題 No.278 連続する整数の和(2)
ユーザー chocoruskchocorusk
提出日時 2019-07-10 20:17:07
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 338 ms / 2,000 ms
コード長 242 bytes
コンパイル時間 67 ms
使用メモリ 7,784 KB
最終ジャッジ日時 2022-12-12 05:43:41
合計ジャッジ時間 3,790 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 16 ms
7,532 KB
testcase_01 AC 15 ms
7,536 KB
testcase_02 AC 278 ms
7,624 KB
testcase_03 AC 15 ms
7,720 KB
testcase_04 AC 16 ms
7,780 KB
testcase_05 AC 19 ms
7,708 KB
testcase_06 AC 21 ms
7,532 KB
testcase_07 AC 22 ms
7,668 KB
testcase_08 AC 260 ms
7,564 KB
testcase_09 AC 260 ms
7,784 KB
testcase_10 AC 338 ms
7,628 KB
testcase_11 AC 252 ms
7,576 KB
testcase_12 AC 15 ms
7,676 KB
testcase_13 AC 216 ms
7,548 KB
testcase_14 AC 172 ms
7,536 KB
testcase_15 AC 189 ms
7,548 KB
testcase_16 AC 157 ms
7,536 KB
testcase_17 AC 270 ms
7,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)
n=int(input())
g=gcd(n*(n+1)//2, n)
ans=0
for i in range(1, g+1):
    if i*i>g:
        break
    if g%i==0:
        ans+=i
        if i*i<g:
            ans+=g//i
print(ans)
0