結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
ckawatak
|
| 提出日時 | 2017-07-06 00:01:29 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 496 bytes |
| コンパイル時間 | 371 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-10-05 20:17:04 |
| 合計ジャッジ時間 | 1,906 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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