結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
nohakai3
|
| 提出日時 | 2022-10-16 16:16:32 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 5,000 ms |
| コード長 | 269 bytes |
| コンパイル時間 | 137 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-06-27 11:26:45 |
| 合計ジャッジ時間 | 2,326 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
from collections import deque
n=int(input())
dp=[-1]*(n+1)
dp[1]=1
q=deque()
q.append(1)
while q:
i=q.popleft()
dist=bin(i).count("1")
for j in [i-dist,i+dist]:
if 1<=j<=n and dp[j]==-1:
dp[j]=dp[i]+1
q.append(j)
print(dp[n])
nohakai3