結果

問題 No.3 ビットすごろく
ユーザー foumi
提出日時 2019-04-07 08:45:54
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 918 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-26 09:53:22
合計ジャッジ時間 2,046 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

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