結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,880 KB
testcase_01 AC 30 ms
10,624 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 507 ms
11,264 KB
testcase_04 AC 81 ms
10,880 KB
testcase_05 AC 2,142 ms
11,428 KB
testcase_06 AC 622 ms
11,264 KB
testcase_07 AC 225 ms
10,880 KB
testcase_08 AC 1,315 ms
11,264 KB
testcase_09 AC 3,505 ms
12,032 KB
testcase_10 AC 4,516 ms
12,288 KB
testcase_11 AC 3,009 ms
11,496 KB
testcase_12 AC 2,014 ms
11,408 KB
testcase_13 AC 371 ms
11,136 KB
testcase_14 AC 4,431 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)):
            k=bin(c[i]).count("1")
            if c[i]+k<=N:
                c.append(c[i]+k)
            if c[i]-k>0:
                c.append(c[i]-k)
        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