結果

問題 No.688 E869120 and Constructing Array 2
ユーザー a01sa01to
提出日時 2025-04-18 00:50:58
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 691 bytes
コンパイル時間 2,911 ms
コンパイル使用メモリ 272,604 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-18 00:51:02
合計ジャッジ時間 4,027 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int k;
  cin >> k;
  for (int len = 1; len <= 30; ++len) {
    for (int zero = 0; zero <= len; ++zero) {
      int one = len - zero;
      ll cnt = (1LL << zero) * (one * (one - 1) / 2);
      if (cnt == k) {
        cout << len << '\n';
        rep(_, zero) cout << "0 ";
        rep(_, one) cout << "1 ";
        cout << '\n';
        return 0;
      }
    }
  }
  assert(false);
  return 0;
}
0