結果
| 問題 | No.294 SuperFizzBuzz |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-17 15:26:01 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 104 ms / 5,000 ms |
| コード長 | 884 bytes |
| 記録 | |
| コンパイル時間 | 393 ms |
| コンパイル使用メモリ | 20,844 KB |
| 実行使用メモリ | 16,472 KB |
| 最終ジャッジ日時 | 2026-05-24 12:37:13 |
| 合計ジャッジ時間 | 3,335 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#!/usr/bin/env python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from 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 1
if N >= 5 and i == 2:
return 1
return 0
ret = 0
if i in [0, 2]:
ret = 1
ret += f((N - 3) // 10, i)
ret += f((N - 5) // 10, (i - 5) % 3)
return ret
def cnt_super_fz(N):
return f((N - 5) // 10, 1)
def solve(K):
left = 0
right = 10 ** 50
while left + 1 < right:
x = (left + right) // 2
if cnt_super_fz(x) >= K:
right = x
else:
left = x
return right
# %%
print(solve(int(read())))
maspy