結果

問題 No.3 ビットすごろく
ユーザー tkr182tkr182
提出日時 2018-10-01 11:35:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 498 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2024-04-20 14:02:40
合計ジャッジ時間 28,149 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 475 ms
11,136 KB
testcase_04 AC 77 ms
11,008 KB
testcase_05 AC 2,019 ms
11,556 KB
testcase_06 AC 571 ms
11,264 KB
testcase_07 AC 213 ms
11,008 KB
testcase_08 AC 1,228 ms
11,392 KB
testcase_09 AC 3,110 ms
12,284 KB
testcase_10 AC 4,177 ms
12,416 KB
testcase_11 AC 2,687 ms
11,624 KB
testcase_12 AC 1,894 ms
11,528 KB
testcase_13 AC 335 ms
11,136 KB
testcase_14 AC 4,080 ms
12,412 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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