結果
問題 | No.294 SuperFizzBuzz |
ユーザー |
![]() |
提出日時 | 2020-03-17 15:26:01 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 44 ms / 5,000 ms |
コード長 | 884 bytes |
コンパイル時間 | 452 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 13,056 KB |
最終ジャッジ日時 | 2024-11-30 22:43:02 |
合計ジャッジ時間 | 1,406 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#!/usr/bin/env python3.8# %%import sysread = sys.stdin.buffer.readreadline = sys.stdin.buffer.readlinereadlines = sys.stdin.buffer.readlinesfrom functools import lru_cache# %%@lru_cache(None)def f(N, i):"""1以上N以下のうち、3と5のみからなり、mod 3 で i のものを数える"""if N < 10:if N >= 3 and i == 0:return 1if N >= 5 and i == 2:return 1return 0ret = 0if i in [0, 2]:ret = 1ret += f((N - 3) // 10, i)ret += f((N - 5) // 10, (i - 5) % 3)return retdef cnt_super_fz(N):return f((N - 5) // 10, 1)def solve(K):left = 0right = 10 ** 50while left + 1 < right:x = (left + right) // 2if cnt_super_fz(x) >= K:right = xelse:left = xreturn right# %%print(solve(int(read())))