結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,088 KB
testcase_01 AC 30 ms
10,088 KB
testcase_02 AC 29 ms
10,088 KB
testcase_03 AC 59 ms
10,380 KB
testcase_04 AC 31 ms
10,148 KB
testcase_05 AC 321 ms
10,836 KB
testcase_06 AC 64 ms
10,432 KB
testcase_07 AC 33 ms
10,248 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 275 ms
10,812 KB
testcase_13 AC 54 ms
10,332 KB
testcase_14 AC 3,364 ms
11,224 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):
  if F[N][1] != -1:
    return F
  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
    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
check(F, 1)
print(F[N][1])
0