結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,048 KB
testcase_01 AC 30 ms
10,048 KB
testcase_02 AC 29 ms
10,048 KB
testcase_03 AC 34 ms
10,496 KB
testcase_04 WA -
testcase_05 AC 38 ms
11,100 KB
testcase_06 AC 34 ms
10,556 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 39 ms
11,076 KB
testcase_13 AC 33 ms
10,416 KB
testcase_14 AC 43 ms
11,656 KB
testcase_15 AC 47 ms
12,048 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 28 ms
10,048 KB
testcase_22 AC 44 ms
11,672 KB
testcase_23 AC 46 ms
12,080 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 #

#!/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')
F[1][1] = 1
F[N][1] = -1
def check(F, p):
  n = F[p][0]
  if p - n > 0 and F[p - n][1] < 1:
    F[p - n][1] = F[p][1] + 1
    F = check(F, p - n)
  if p + n < N + 1 and F[p + n][1] < 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