結果
| 問題 | No.3 ビットすごろく | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-10-28 18:33:48 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 67 ms / 5,000 ms | 
| コード長 | 404 bytes | 
| コンパイル時間 | 302 ms | 
| コンパイル使用メモリ | 82,372 KB | 
| 実行使用メモリ | 77,628 KB | 
| 最終ジャッジ日時 | 2024-10-07 08:05:24 | 
| 合計ジャッジ時間 | 3,449 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 33 | 
ソースコード
N = int(input())
jmp_to = {x: [x-d, x+d] for x,d in [[x, bin(x).count("1")] for x in range(1,N)]}
pos = {1}
passed = set()
cnt = 1
while len(pos) > 0:
    if N in pos:
        break
    passed.update(pos)
    new_pos = set()
    for i in pos:
        if i > 0 and i < N:
            new_pos.update(jmp_to[i])
    new_pos = new_pos - passed
    pos = new_pos
    cnt += 1
else:
    cnt = -1
print(cnt)
            
            
            
        