結果

問題 No.3 ビットすごろく
ユーザー にゃんにゃん
提出日時 2022-02-12 23:34:29
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 389 bytes
コンパイル時間 405 ms
コンパイル使用メモリ 10,592 KB
実行使用メモリ 8,464 KB
最終ジャッジ日時 2023-09-11 12:13:50
合計ジャッジ時間 3,004 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,788 KB
testcase_01 AC 15 ms
7,856 KB
testcase_02 AC 15 ms
7,804 KB
testcase_03 AC 19 ms
7,728 KB
testcase_04 AC 16 ms
7,880 KB
testcase_05 AC 28 ms
7,820 KB
testcase_06 AC 20 ms
7,904 KB
testcase_07 AC 17 ms
7,800 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 28 ms
7,964 KB
testcase_13 AC 18 ms
7,804 KB
testcase_14 AC 42 ms
8,320 KB
testcase_15 AC 67 ms
8,300 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 18 ms
7,936 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 15 ms
7,848 KB
testcase_22 AC 43 ms
8,452 KB
testcase_23 AC 68 ms
8,316 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 15 ms
7,808 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 15 ms
7,804 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def bit(x):
    x = bin(x)
    x = x.count('1')
    return x

N = int(input())
A = []
A.append(1)
ans = 1
while True:
    if len(A)!=len(set(A)):
        print(-1)
        break
    if A[-1]!=N:
        if A[-1]+bit(A[-1])<=N:
            A.append(A[-1] + bit(A[-1]))
        else:
            A.append(A[-1] - bit(A[-1]))
        ans+=1
    elif A[-1]==N:
        print(ans)
        break
0