結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー 37zigen37zigen
提出日時 2019-08-31 00:44:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 887 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 67,820 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-06 11:56:58
合計ジャッジ時間 3,069 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 42 ms
4,380 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 2 ms
4,416 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 35 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 9 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,424 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 6 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 21 ms
4,376 KB
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>

const int MAXN = 112345;
long long dp[MAXN];

int main() {
  for (int i = 0; i < MAXN; ++i) {
    dp[i] = 1LL << 60;
  }
  dp[0] = 0;
  int N;
  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    for (int j = 1; j*j + i <= N; ++j) {
      dp[i + j*j] = std::min(dp[i + j*j], dp[i] + j);
    }
  }
  int res = N;
  int parity = 0;
  while (res > 0) {
    bool upd = false;
    for (int i = parity + 1; i*i <= res; i += 2) {
      if (dp[res - i*i] + i > dp[res]) continue;
      for (int j = parity; j < i + parity; ++j) std::cout << j%2;
      res -= i*i;
      parity = 0;
      upd = true;
      break;
    }
    if (upd) continue;
    for (int i = ((int)std::sqrt(res))/2*2; i >= 1; i -= 2) {
      for (int j = parity; j < i + parity; ++j) std::cout << j%2;
      res -= i*i;
      parity = 1;
      break;
    }
  }
  std::cout << std::endl;
}
0