結果

問題 No.634 硬貨の枚数1
ユーザー Yukino DX.Yukino DX.
提出日時 2023-11-17 16:23:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,271 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,088 KB
最終ジャッジ日時 2023-11-17 16:24:12
合計ジャッジ時間 29,978 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 40 ms
59,388 KB
testcase_03 AC 39 ms
59,388 KB
testcase_04 AC 39 ms
59,388 KB
testcase_05 AC 36 ms
53,460 KB
testcase_06 AC 39 ms
59,388 KB
testcase_07 AC 41 ms
59,388 KB
testcase_08 AC 40 ms
59,388 KB
testcase_09 AC 35 ms
53,460 KB
testcase_10 AC 40 ms
59,388 KB
testcase_11 AC 39 ms
59,388 KB
testcase_12 AC 40 ms
59,388 KB
testcase_13 AC 42 ms
59,388 KB
testcase_14 AC 51 ms
63,952 KB
testcase_15 AC 311 ms
75,088 KB
testcase_16 AC 80 ms
66,000 KB
testcase_17 AC 73 ms
66,000 KB
testcase_18 AC 60 ms
63,952 KB
testcase_19 AC 50 ms
61,864 KB
testcase_20 AC 54 ms
63,952 KB
testcase_21 AC 310 ms
75,088 KB
testcase_22 AC 91 ms
66,000 KB
testcase_23 AC 102 ms
70,096 KB
testcase_24 AC 40 ms
59,388 KB
testcase_25 AC 42 ms
59,388 KB
testcase_26 AC 43 ms
59,516 KB
testcase_27 AC 42 ms
59,388 KB
testcase_28 AC 40 ms
59,388 KB
testcase_29 AC 43 ms
59,516 KB
testcase_30 AC 43 ms
59,516 KB
testcase_31 AC 43 ms
59,516 KB
testcase_32 AC 42 ms
59,496 KB
testcase_33 AC 42 ms
59,516 KB
testcase_34 AC 49 ms
63,952 KB
testcase_35 AC 58 ms
63,952 KB
testcase_36 AC 91 ms
68,048 KB
testcase_37 AC 66 ms
63,952 KB
testcase_38 AC 55 ms
63,952 KB
testcase_39 AC 294 ms
75,088 KB
testcase_40 AC 167 ms
75,088 KB
testcase_41 AC 113 ms
70,096 KB
testcase_42 AC 91 ms
66,000 KB
testcase_43 AC 79 ms
66,000 KB
testcase_44 AC 36 ms
53,460 KB
testcase_45 AC 46 ms
59,484 KB
testcase_46 AC 51 ms
61,872 KB
testcase_47 AC 69 ms
63,952 KB
testcase_48 AC 37 ms
53,460 KB
testcase_49 AC 48 ms
61,872 KB
testcase_50 AC 126 ms
68,048 KB
testcase_51 AC 90 ms
72,144 KB
testcase_52 AC 37 ms
53,460 KB
testcase_53 AC 37 ms
53,460 KB
testcase_54 AC 36 ms
53,460 KB
testcase_55 AC 1,271 ms
75,088 KB
testcase_56 AC 1,214 ms
75,088 KB
testcase_57 AC 1,169 ms
75,088 KB
testcase_58 AC 1,259 ms
75,088 KB
testcase_59 AC 1,183 ms
75,088 KB
testcase_60 AC 1,242 ms
75,088 KB
testcase_61 AC 1,125 ms
75,088 KB
testcase_62 AC 1,145 ms
75,088 KB
testcase_63 AC 1,104 ms
75,088 KB
testcase_64 AC 1,091 ms
75,088 KB
testcase_65 AC 1,073 ms
75,088 KB
testcase_66 AC 1,073 ms
75,088 KB
testcase_67 AC 1,039 ms
75,088 KB
testcase_68 AC 1,071 ms
75,088 KB
testcase_69 AC 1,068 ms
75,088 KB
testcase_70 AC 1,053 ms
75,088 KB
testcase_71 AC 1,059 ms
75,088 KB
testcase_72 AC 1,045 ms
75,088 KB
testcase_73 AC 1,035 ms
75,088 KB
testcase_74 AC 1,038 ms
75,088 KB
testcase_75 AC 1,000 ms
75,088 KB
testcase_76 AC 43 ms
61,604 KB
testcase_77 AC 42 ms
59,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import takewhile, count

sys.setrecursionlimit(10**7)

n = int(input())
koukas = [
    k * (k + 1) // 2 for k in takewhile(lambda k: k * (k + 1) // 2 <= n, count(1))
]


def can(m, n):
    if m == 0 or n == 0:
        return m == n

    for kouka in koukas:
        if kouka > n:
            break
        if can(m - 1, n - kouka):
            return True

    return False


for m in count(1):
    if can(m, n):
        print(m)
        exit()
0