結果
問題 |
No.634 硬貨の枚数1
|
ユーザー |
|
提出日時 | 2023-11-17 16:23:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,252 ms / 2,000 ms |
コード長 | 471 bytes |
コンパイル時間 | 527 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 76,032 KB |
最終ジャッジ日時 | 2024-09-26 05:25:54 |
合計ジャッジ時間 | 30,334 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
ソースコード
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()