結果

問題 No.3 ビットすごろく
ユーザー ktny
提出日時 2016-07-18 22:32:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 461 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-10-15 17:05:51
合計ジャッジ時間 2,090 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

array = []
for i in range(1, N):
    array.append(str(bin(i))[2:].count("1"))

count = 0
position = 0
while(position != N - 1):
    if(array[position] == 0):
        count = -1
        break
    elif(position + array[position] <= N - 1):
        n = array[position]
        array[position] = 0
        position += n
        count += 1
    else:
        position -= array[position]
        count += 1

print(count + 1 if count != -1 else count)
0