結果

問題 No.3 ビットすごろく
ユーザー rusa6111rusa6111
提出日時 2019-06-28 22:03:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 465 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 76,744 KB
最終ジャッジ日時 2023-09-14 21:59:56
合計ジャッジ時間 4,587 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,400 KB
testcase_01 AC 74 ms
71,404 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 84 ms
76,360 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 90 ms
76,640 KB
testcase_08 AC 92 ms
76,492 KB
testcase_09 AC 93 ms
76,412 KB
testcase_10 AC 95 ms
76,332 KB
testcase_11 AC 96 ms
76,612 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 93 ms
76,332 KB
testcase_17 AC 94 ms
76,408 KB
testcase_18 AC 92 ms
76,440 KB
testcase_19 AC 95 ms
76,460 KB
testcase_20 AC 84 ms
76,436 KB
testcase_21 AC 73 ms
71,300 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 95 ms
76,432 KB
testcase_25 AC 95 ms
76,480 KB
testcase_26 AC 73 ms
71,132 KB
testcase_27 AC 90 ms
76,320 KB
testcase_28 AC 94 ms
76,644 KB
testcase_29 AC 95 ms
76,428 KB
testcase_30 AC 75 ms
71,464 KB
testcase_31 AC 76 ms
71,340 KB
testcase_32 AC 93 ms
76,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def bc(n):
    c=0
    while n:
        if n%2:
            n-=1
            c+=1
        n=int(n/2)
    return c

n=int(input())
b=[bc(i+1) for i in range(n)]
c=[9999999 for i in range(n)]
c[0]=1
v=1
while(v):
    v=0
    for j in range(n):
        if j-b[j]>=0 and c[j-b[j]]>c[j]+1:
            v=1
            c[j-b[j]]=c[j]+1
        if j+b[j]<n and c[j+b[j]]>c[j]+1:
            v=1
            c[j+b[j]]=c[j]+1
if c[n-1]:
    print(c[n-1])
else:
    print(-1)
0