結果

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

テストケース

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

ソースコード

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:
    p=len(t)-1
else:
    p=-1
print (p)
0