結果

問題 No.278 連続する整数の和(2)
ユーザー chocoruskchocorusk
提出日時 2019-07-10 20:17:07
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 242 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,632 KB
実行使用メモリ 7,924 KB
最終ジャッジ日時 2023-08-06 02:46:12
合計ジャッジ時間 3,432 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,892 KB
testcase_01 AC 15 ms
7,924 KB
testcase_02 AC 262 ms
7,848 KB
testcase_03 AC 15 ms
7,852 KB
testcase_04 AC 16 ms
7,848 KB
testcase_05 AC 19 ms
7,772 KB
testcase_06 AC 22 ms
7,860 KB
testcase_07 AC 21 ms
7,784 KB
testcase_08 AC 245 ms
7,840 KB
testcase_09 AC 243 ms
7,804 KB
testcase_10 AC 310 ms
7,852 KB
testcase_11 AC 238 ms
7,836 KB
testcase_12 AC 15 ms
7,840 KB
testcase_13 AC 203 ms
7,868 KB
testcase_14 AC 161 ms
7,796 KB
testcase_15 AC 198 ms
7,808 KB
testcase_16 AC 146 ms
7,844 KB
testcase_17 AC 251 ms
7,792 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