結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-13 04:56:31 |
| 言語 | Python3 (3.14.3 + numpy 2.4.2 + scipy 1.17.0) |
| 結果 |
AC
|
| 実行時間 | 98 ms / 5,000 ms |
| コード長 | 294 bytes |
| 記録 | |
| コンパイル時間 | 328 ms |
| コンパイル使用メモリ | 20,960 KB |
| 実行使用メモリ | 15,484 KB |
| 最終ジャッジ日時 | 2026-03-22 05:33:02 |
| 合計ジャッジ時間 | 4,349 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
def upd(x,t):
if 0<x<=N and A[x]==0:
Q.append(x)
A[x]=A[t]+1
def bfs():
while Q:
t=Q.pop(0)
if t==N:return A[N]
c=bin(t)[2:].count('1')
upd(t+c,t)
upd(t-c,t)
return -1
N=int(input())
A=[0]*10001
A[1]=1
Q=[1]
print(bfs())