結果

問題 No.276 連続する整数の和(1)
ユーザー けむけむけむけむ
提出日時 2021-07-23 00:59:12
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 18 ms / 1,000 ms
コード長 426 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 10,668 KB
実行使用メモリ 8,076 KB
最終ジャッジ日時 2023-09-24 21:51:55
合計ジャッジ時間 1,096 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,896 KB
testcase_01 AC 16 ms
7,928 KB
testcase_02 AC 16 ms
8,076 KB
testcase_03 AC 17 ms
7,884 KB
testcase_04 AC 17 ms
8,040 KB
testcase_05 AC 18 ms
8,032 KB
testcase_06 AC 18 ms
7,928 KB
testcase_07 AC 18 ms
7,928 KB
testcase_08 AC 17 ms
7,940 KB
testcase_09 AC 16 ms
7,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def seisuwa(N):
    M = N * (N - 1) // 2
    Nl = []
    for i in range(1, int(math.sqrt(N)) + 1):
        if N % i == 0:
            Nl.append(i)
            Nl.append(N // i)
    Nl = sorted(Nl)
    for j in range(1, len(Nl) + 1):
        if M % Nl[-j] == 0:
            ans = Nl[-j]
            break
    return ans

def main():
    N = int(input())
    print(seisuwa(N))

if __name__ == '__main__':
    main()
0