結果

問題 No.3 ビットすごろく
ユーザー mkawa2mkawa2
提出日時 2019-04-18 16:02:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 419 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 9,000 KB
最終ジャッジ日時 2023-09-14 01:16:12
合計ジャッジ時間 2,245 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,792 KB
testcase_01 AC 16 ms
7,800 KB
testcase_02 AC 16 ms
7,800 KB
testcase_03 AC 19 ms
8,316 KB
testcase_04 AC 17 ms
7,944 KB
testcase_05 AC 22 ms
8,356 KB
testcase_06 AC 19 ms
8,312 KB
testcase_07 AC 18 ms
7,876 KB
testcase_08 AC 21 ms
8,400 KB
testcase_09 AC 24 ms
8,812 KB
testcase_10 AC 26 ms
9,000 KB
testcase_11 AC 24 ms
8,320 KB
testcase_12 AC 23 ms
8,340 KB
testcase_13 AC 19 ms
8,236 KB
testcase_14 AC 26 ms
8,952 KB
testcase_15 AC 28 ms
8,868 KB
testcase_16 AC 27 ms
8,956 KB
testcase_17 AC 27 ms
8,884 KB
testcase_18 AC 18 ms
8,268 KB
testcase_19 AC 28 ms
8,864 KB
testcase_20 AC 17 ms
7,804 KB
testcase_21 AC 16 ms
7,940 KB
testcase_22 AC 25 ms
8,984 KB
testcase_23 AC 28 ms
8,784 KB
testcase_24 AC 28 ms
8,996 KB
testcase_25 AC 28 ms
8,960 KB
testcase_26 AC 16 ms
7,948 KB
testcase_27 AC 19 ms
8,384 KB
testcase_28 AC 28 ms
8,900 KB
testcase_29 AC 25 ms
8,956 KB
testcase_30 AC 16 ms
7,872 KB
testcase_31 AC 16 ms
7,836 KB
testcase_32 AC 23 ms
8,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
ps=[1]
cnt=1
log=set([1])
while n not in ps:
    nps=[]
    for p in ps:
        dp=format(p,"b").count("1")
        np=p+dp
        if 0 < np < n + 1 and np not in log:
            nps+=[np]
            log.add(np)
        np=p-dp
        if 0 < np < n + 1 and np not in log:
            nps+=[np]
            log.add(np)
    if len(nps)==0:
        cnt=-1
        break
    cnt+=1
    ps=nps
print(cnt)
0