結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,112 KB
testcase_01 AC 29 ms
10,112 KB
testcase_02 AC 29 ms
10,112 KB
testcase_03 AC 33 ms
10,552 KB
testcase_04 WA -
testcase_05 AC 39 ms
11,156 KB
testcase_06 AC 33 ms
10,612 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 39 ms
11,132 KB
testcase_13 AC 33 ms
10,472 KB
testcase_14 AC 43 ms
11,712 KB
testcase_15 AC 48 ms
12,104 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 28 ms
10,112 KB
testcase_22 AC 44 ms
11,728 KB
testcase_23 AC 47 ms
12,136 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 29 ms
10,112 KB
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[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 > 0 and F[p - n][1] < 1:
    F[p - n][1] = F[p][1] + 1
    check(F, p - n)
  if p + n < N + 1 and F[p + n][1] < 1:
    F[p + n][1] = F[p][1] + 1
    check(F, p + n)
  return F
F = check(F, 1)
print(F[N][1])
0