結果

問題 No.3 ビットすごろく
ユーザー tomiyancetomiyance
提出日時 2019-11-14 07:43:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 422 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 12,160 KB
最終ジャッジ日時 2024-09-21 21:19:54
合計ジャッジ時間 3,358 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 WA * 7 RE * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
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]
  c = F[p][1]
  if p - n > 0 and F[p - n][1] < 1:
    F[p - n][1] = c + 1
    check(F, p - n)
  if p + n < N + 1 and F[p + n][1] < 1:
    F[p + n][1] = c + 1
    check(F, p + n)
  return F
R = check(F, 1)
print(R[N][1])
0