結果

問題 No.3 ビットすごろく
コンテスト
ユーザー foumi
提出日時 2019-04-07 08:45:54
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 918 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 621 ms
コンパイル使用メモリ 20,572 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2026-03-13 02:21:38
合計ジャッジ時間 5,213 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())

def play():
    global count
    global current_location
    if current_location == N:
        print(current_location)
    else:
        for n in range(current_location, 10**5):
            move = bin(current_location).count('1')
            if current_location + move == N:
                count += 1
                print(count)
                break
            elif current_location + move < N:
                current_location += move
                map.append(n)
                count += 1
            elif current_location + move > N:
                current_location -= move
                if current_location in map:
                    print(-1)
                    break
                else:
                    map.append(n)
                    count += 1
                    switch()
                    break

def switch():
    play()

current_location = 1
count = 1
map = []

play()
0