結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-28 07:20:24 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 43 ms / 5,000 ms |
| コード長 | 543 bytes |
| 記録 | |
| コンパイル時間 | 1,769 ms |
| コンパイル使用メモリ | 84,944 KB |
| 実行使用メモリ | 73,216 KB |
| 最終ジャッジ日時 | 2026-04-20 18:24:52 |
| 合計ジャッジ時間 | 3,309 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
from collections import *
from functools import *
from itertools import *
from heapq import *
import sys,math
input = sys.stdin.readline
N = int(input())
dist = defaultdict(lambda: -1)
v = deque()
dist[1]=1
v.append(1)
while v:
x = v.popleft()
delta = bin(x).count('1')
e = [x-delta,x+delta]
for ix in e:
if dist[ix]!=-1:
continue
if ix>N:
continue
dist[ix]=dist[x]+1
v.append(ix)
print(dist[N])