結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
yoza
|
| 提出日時 | 2014-11-14 20:41:08 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 491 bytes |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-12-31 10:51:39 |
| 合計ジャッジ時間 | 2,594 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 WA * 1 |
ソースコード
n = int(input())
b = [bin(i+1).count("1") for i in range(n)]
cell = [-1] * n
cell[0] = 0
queue = [[0, 2]]
while queue:
num, cost = queue.pop(0)
if num == n - 1:
break
if num - b[num] >= 0 and cell[num - b[num]] == -1:
cell[num - b[num]] = cost
queue.append([num - b[num], cost + 1])
if num + b[num] < n and cell[num + b[num]] == -1:
cell[num + b[num]] = cost
queue.append([num + b[num], cost + 1])
print(cell[n-1])
yoza