結果

問題 No.3 ビットすごろく
ユーザー tomiyancetomiyance
提出日時 2019-11-14 09:04:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 11,900 KB
実行使用メモリ 21,636 KB
最終ジャッジ日時 2023-10-21 19:55:38
合計ジャッジ時間 11,273 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
21,636 KB
testcase_01 AC 27 ms
10,092 KB
testcase_02 AC 27 ms
10,092 KB
testcase_03 AC 53 ms
10,384 KB
testcase_04 AC 27 ms
10,152 KB
testcase_05 AC 306 ms
10,840 KB
testcase_06 AC 58 ms
10,436 KB
testcase_07 AC 28 ms
10,252 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 253 ms
10,816 KB
testcase_13 AC 48 ms
10,336 KB
testcase_14 AC 3,062 ms
11,228 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 #

#!/usr/bin/env python
import sys
sys.setrecursionlimit(10000)
N = int(input())
F = [[0 for j in range(2)] for i in range(N+1)]
for i in range(1,N+1):
  F[i][0] = format(i,'b').count('1')
  # print(i,format(i,'b'),format(i,'b').count('1'))
F[N][1] = -1
F[1][1] = 1
def check(F, p):
  n = F[p][0]
  if F[N][1] > 0:
    return F
  if p + n < N + 1 and (F[p + n][1] < 1 or F[p + n][1] > F[p][1]):
    F[p + n][1] = F[p][1] + 1
    check(F, p + n)
  if p - n > 0 and (F[p - n][1] < 1 or F[p - n][1] > F[p][1]):
    F[p - n][1] = F[p][1] + 1
    check(F, p - n)
  return F
F = check(F, 1)
print(F[N][1])
0