結果

問題 No.634 硬貨の枚数1
ユーザー GrayCoder
提出日時 2018-07-29 16:33:36
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 481 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-07-18 02:59:33
合計ジャッジ時間 4,158 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 75
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

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

    tnum = set()
    for i in range(1, N + 1):
        n = i * (i + 1) // 2
        tnum.add(n)
        if n >= N:
            break

    if N in tnum:
        ans = 1
    else:
        for i in tnum:
            n = N - i
            if n in tnum:
                ans = 2
                break
        else:
            ans = 3

    print(ans)

main()
0