結果
問題 | No.3 ビットすごろく |
ユーザー |
![]() |
提出日時 | 2024-09-30 18:04:59 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 64 ms / 5,000 ms |
コード長 | 426 bytes |
コンパイル時間 | 96 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-09-30 18:05:02 |
合計ジャッジ時間 | 2,216 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
from collections import dequeN = int(input())t = [-1]*(N+1)t[1] = 1q = deque()q.append(1)while q:crt = q.popleft()cnt = 0a = crtwhile a:cnt += a&1a >>= 1p = crt+cntm = crt-cntif p <= N:if t[p] == -1:t[p] = t[crt] + 1q.append(p)if m > 0:if t[m] == -1:t[m] = t[crt] + 1q.append(m)print(t[N])