結果

問題 No.634 硬貨の枚数1
コンテスト
ユーザー Kohei
提出日時 2026-07-25 22:46:44
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 589 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 680 ms
コンパイル使用メモリ 95,980 KB
実行使用メモリ 84,096 KB
最終ジャッジ日時 2026-07-25 22:46:57
合計ジャッジ時間 12,270 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 74 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from bisect import bisect_right
N = int(input())
material = [1]
diff = 2
for i in range(10000):
    sub = material[-1] + diff
    if sub > 10**7:
        break
    material.append(sub)
    diff += 1
start = bisect_right(material, N) - 1
ans = 1e18
for i in range(start, -1, -1): # 使う硬貨の最大値は material[start]
    nokori = N
    cnt = 0
    for j in range(i, -1, -1):
        # 貪欲に使う
        sho, amari = divmod(nokori, material[j])
        cnt += sho
        nokori = amari
        if nokori == 0:
            break
    if ans > cnt:
        ans = cnt
print(ans)
0