結果

問題 No.3 ビットすごろく
ユーザー Shin09shinShin09shin
提出日時 2019-01-18 07:11:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,222 ms / 5,000 ms
コード長 561 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 9,824 KB
最終ジャッジ日時 2023-09-14 01:11:06
合計ジャッジ時間 15,940 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,780 KB
testcase_01 AC 16 ms
7,848 KB
testcase_02 AC 17 ms
7,856 KB
testcase_03 AC 93 ms
8,476 KB
testcase_04 AC 23 ms
8,296 KB
testcase_05 AC 318 ms
8,724 KB
testcase_06 AC 112 ms
8,404 KB
testcase_07 AC 39 ms
8,284 KB
testcase_08 AC 216 ms
8,480 KB
testcase_09 AC 519 ms
9,604 KB
testcase_10 AC 754 ms
9,676 KB
testcase_11 AC 408 ms
8,800 KB
testcase_12 AC 309 ms
8,476 KB
testcase_13 AC 68 ms
8,352 KB
testcase_14 AC 716 ms
9,628 KB
testcase_15 AC 1,191 ms
9,768 KB
testcase_16 AC 1,016 ms
9,772 KB
testcase_17 AC 1,152 ms
9,752 KB
testcase_18 AC 50 ms
8,424 KB
testcase_19 AC 1,214 ms
9,824 KB
testcase_20 AC 20 ms
8,232 KB
testcase_21 AC 16 ms
7,868 KB
testcase_22 AC 730 ms
9,740 KB
testcase_23 AC 1,222 ms
9,748 KB
testcase_24 AC 1,218 ms
9,816 KB
testcase_25 AC 1,183 ms
9,708 KB
testcase_26 AC 15 ms
7,900 KB
testcase_27 AC 79 ms
8,324 KB
testcase_28 AC 973 ms
9,784 KB
testcase_29 AC 428 ms
9,620 KB
testcase_30 AC 16 ms
7,904 KB
testcase_31 AC 17 ms
7,824 KB
testcase_32 AC 371 ms
8,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
a = 1
b = [1]
c = []
g = []
if N == 1:
    print(1)
else:    
    while a:
        c = b
        c = list(set(c))
        f = list(set(b)-set(g))
        for i in range(0,len(f)):
             d = bin(f[i]).count("1")
             p = f[i] + d 
             q = f[i] - d
             if p <= N:
                b.append(p)
             if q > 0:
                b.append(q)
        a += 1
        g = c
        b = list(set(b))
        if N in b:
            print(a)
            break
        if b == c:
            print(-1)
            break
0