結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-04 14:03:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 533 bytes |
| コンパイル時間 | 184 ms |
| コンパイル使用メモリ | 82,436 KB |
| 実行使用メモリ | 72,192 KB |
| 最終ジャッジ日時 | 2024-07-18 13:34:58 |
| 合計ジャッジ時間 | 2,610 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 RE * 1 |
ソースコード
#int(input())
#map(int, input().split())
#list(map(int, input().split()))
N = int(input())
def popcnt(n):
return bin(n).count("1")
to = [[] for i in range(N+1)]
to[1] = [2]
for i in range(2, N+1):
p = popcnt(i)
if i + p <= N:
to[i] = [i+p, i-p]
else:
to[i] = [i-p]
q = [1]
v = [-1] * (N+1)
v[1] = 1
from collections import deque
q = deque(q)
while q:
t = q.popleft()
for x in to[t]:
if v[x] != -1:
continue
v[x] = v[t] + 1
q.append(x)
print(v[N])