結果

問題 No.3 ビットすごろく
ユーザー rocoderrocoder
提出日時 2017-08-04 06:05:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 942 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-04-20 01:52:46
合計ジャッジ時間 2,429 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
11,008 KB
testcase_01 AC 26 ms
10,880 KB
testcase_02 AC 27 ms
10,880 KB
testcase_03 AC 36 ms
10,880 KB
testcase_04 AC 31 ms
10,880 KB
testcase_05 AC 46 ms
11,008 KB
testcase_06 AC 39 ms
10,880 KB
testcase_07 AC 32 ms
11,008 KB
testcase_08 AC 39 ms
11,008 KB
testcase_09 AC 49 ms
11,136 KB
testcase_10 AC 55 ms
11,136 KB
testcase_11 AC 53 ms
11,136 KB
testcase_12 AC 45 ms
11,008 KB
testcase_13 AC 33 ms
10,880 KB
testcase_14 AC 53 ms
11,136 KB
testcase_15 AC 61 ms
11,392 KB
testcase_16 AC 59 ms
11,264 KB
testcase_17 AC 65 ms
11,264 KB
testcase_18 AC 32 ms
10,880 KB
testcase_19 AC 60 ms
11,392 KB
testcase_20 AC 29 ms
10,880 KB
testcase_21 AC 27 ms
10,880 KB
testcase_22 AC 53 ms
11,136 KB
testcase_23 AC 60 ms
11,264 KB
testcase_24 AC 58 ms
11,392 KB
testcase_25 AC 60 ms
11,264 KB
testcase_26 WA -
testcase_27 AC 35 ms
10,880 KB
testcase_28 AC 60 ms
11,264 KB
testcase_29 AC 47 ms
11,264 KB
testcase_30 AC 27 ms
10,880 KB
testcase_31 AC 27 ms
10,880 KB
testcase_32 AC 46 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# your code goes here
def m(nu):
    bi=format (nu,'b')
    C=0
    for i in range (len (bi)):
        if bi[i]=="1":
            C+=1
        #    print("bi")
      #      print (nu)
    return C
N=int(input())
Nd=0
v=[0]*N
v[0]=1
t=[[1]]
i=0
while Nd<1:
    j=0
    t.append([])
    while j<len(t[i]):
        mt=m(t[i][j])+t[i][j]
    #    print (mt)
        if mt==N:
            Nd=1
        elif mt<N and mt>0:     
            if v[mt-1]==0:
         #       print (v)
                v[mt-1]=1
                t[i+1].append(mt)
        j+=1
    #    print (t[i])
    j-=len(t[i])
    while j<len(t[i]):
        mt=-1*m(t[i][j])+t[i][j]
        if mt==N:
            Nd=1
        elif mt<N and mt>0:
            if v[mt-1]==0:
                t[i+1].append(mt)
                v[mt-1]=1
        j+=1
   # print (t)
   # print (i)
    if Nd<1 and t[i+1]==[]:
        Nd=2
    i+=1
if Nd==1 or N==1:
    p=len(t)
else:
    p=-1
print (p)
0