結果
問題 | No.3 ビットすごろく |
ユーザー |
![]() |
提出日時 | 2021-11-08 11:36:32 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 67 ms / 5,000 ms |
コード長 | 462 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-11-15 22:30:34 |
合計ジャッジ時間 | 2,706 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
n = int(input()) board = [-1 for _ in range(n+1)] board[1] = 1 i = 1 while i <= n: c = bin(i)[2:].count("1") if board[i] < 0: i += 1 continue if i+c < n+1 and (board[i+c] > board[i]+1 or board[i+c] == -1): board[i+c] = board[i] + 1 if i-c > 0: if board[i-c] > board[i]+1 or board[i-c] == -1: board[i-c] = board[i]+1 i = i-c continue i += 1 print(board[n])