結果
| 問題 |
No.294 SuperFizzBuzz
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 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 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