結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
ckawatak
|
| 提出日時 | 2017-07-06 00:01:29 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 496 bytes |
| 記録 | |
| コンパイル時間 | 328 ms |
| コンパイル使用メモリ | 20,700 KB |
| 実行使用メモリ | 15,360 KB |
| 最終ジャッジ日時 | 2026-04-21 06:02:13 |
| 合計ジャッジ時間 | 4,874 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 16 |
ソースコード
N = int(input())
def nbit(n):
b = 0
while 0 < n:
b += n & 1
n >>= 1
return b
count = 1
current = 1
done = {}
while current != N:
bit = nbit(current)
next = current + bit
count += 1
if next == N:
break
elif next < N and next not in done:
done[next] = 1
current = next
elif N < next and next not in done:
done[next] = 1
current = current - bit
else:
count = -1
break
print(count)
ckawatak