結果

問題 No.3 ビットすごろく
ユーザー tkr182tkr182
提出日時 2018-10-01 12:18:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,202 ms / 5,000 ms
コード長 523 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 9,820 KB
最終ジャッジ日時 2023-09-14 01:08:19
合計ジャッジ時間 15,567 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,768 KB
testcase_01 AC 17 ms
7,772 KB
testcase_02 AC 16 ms
7,920 KB
testcase_03 AC 89 ms
8,400 KB
testcase_04 AC 22 ms
8,368 KB
testcase_05 AC 312 ms
8,612 KB
testcase_06 AC 111 ms
8,360 KB
testcase_07 AC 38 ms
8,248 KB
testcase_08 AC 211 ms
8,516 KB
testcase_09 AC 505 ms
9,632 KB
testcase_10 AC 746 ms
9,724 KB
testcase_11 AC 398 ms
8,764 KB
testcase_12 AC 304 ms
8,580 KB
testcase_13 AC 67 ms
8,484 KB
testcase_14 AC 708 ms
9,760 KB
testcase_15 AC 1,152 ms
9,768 KB
testcase_16 AC 997 ms
9,668 KB
testcase_17 AC 1,145 ms
9,688 KB
testcase_18 AC 49 ms
8,304 KB
testcase_19 AC 1,202 ms
9,792 KB
testcase_20 AC 20 ms
8,204 KB
testcase_21 AC 15 ms
7,864 KB
testcase_22 AC 703 ms
9,736 KB
testcase_23 AC 1,194 ms
9,820 KB
testcase_24 AC 1,191 ms
9,816 KB
testcase_25 AC 1,147 ms
9,768 KB
testcase_26 AC 16 ms
7,856 KB
testcase_27 AC 76 ms
8,256 KB
testcase_28 AC 946 ms
9,676 KB
testcase_29 AC 420 ms
9,580 KB
testcase_30 AC 16 ms
7,772 KB
testcase_31 AC 17 ms
7,772 KB
testcase_32 AC 364 ms
8,812 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