結果

問題 No.3 ビットすごろく
ユーザー kutsutama
提出日時 2018-03-01 23:11:13
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 600 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-12-26 01:08:52
合計ジャッジ時間 2,449 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

def CountOne(num):
    res = 0
    while num >= 1:
        if num % 2 == 1:
            res += 1
        num //= 2
    return res

n = int(input())
u = set()

res = 1
p = 1
while p != n:
    u.add(p)
    go = CountOne(p)
    if p + go <= n:
        if (p + go) not in u:
            p += go
        else:
            if (p - go) not in u:
                p -= go
            else:
                res = -1
                break
    else:
        if (p - go) not in u:
            p -= go
        else:
            res = -1
            break
    res += 1

print(res)
0