結果

問題 No.3 ビットすごろく
ユーザー tomiyancetomiyance
提出日時 2019-11-14 09:07:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 574 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 11,940 KB
実行使用メモリ 11,308 KB
最終ジャッジ日時 2023-10-21 19:55:57
合計ジャッジ時間 17,874 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,124 KB
testcase_01 AC 30 ms
10,124 KB
testcase_02 AC 32 ms
10,124 KB
testcase_03 AC 57 ms
10,416 KB
testcase_04 AC 34 ms
10,188 KB
testcase_05 AC 304 ms
10,872 KB
testcase_06 AC 62 ms
10,468 KB
testcase_07 AC 44 ms
10,288 KB
testcase_08 AC 157 ms
10,712 KB
testcase_09 AC 1,541 ms
11,112 KB
testcase_10 AC 4,269 ms
11,308 KB
testcase_11 AC 951 ms
11,016 KB
testcase_12 AC 266 ms
10,848 KB
testcase_13 AC 52 ms
10,368 KB
testcase_14 AC 3,191 ms
11,260 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 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
    F = 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
    F = check(F, p - n)
  return F
F = check(F, 1)
print(F[N][1])
0