結果

問題 No.3 ビットすごろく
ユーザー takopom55
提出日時 2016-12-28 16:27:04
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-12-15 07:49:57
合計ジャッジ時間 2,581 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    route = list(range(1, N + 1))
    current = 0
    moved = 1
    over = 0
    while route[current] != N:
        step = get_step(route[current])
        if current + step < len(route):
            current += step
        else:
            current -= step
            over += 1
            if over > 1:
                moved = -1
                break
        moved += 1
    print(moved)
    
def get_step(value):
    step = 0
    while value > 0:
        if (value & 1) == 1:
            step += 1
        value >>= 1
    return step

if __name__ == '__main__':
    main()
0