結果

問題 No.688 E869120 and Constructing Array 2
ユーザー Mister
提出日時 2020-04-16 10:00:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 701 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 66,804 KB
最終ジャッジ日時 2025-01-09 19:25:22
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

constexpr int N = 30;

void solve() {
    int k;
    std::cin >> k;

    for (int o = 2; o <= N; ++o) {
        int p = o * (o - 1) / 2;
        if (k % p != 0) continue;

        int z = 0;
        while ((1 << z) < k / p) ++z;
        if ((1 << z) != k / p || o + z > N) continue;

        std::cout << o + z << std::endl;
        for (int i = 0; i < o; ++i) {
            std::cout << 1 << " ";
        }
        for (int i = 0; i < z; ++i) {
            std::cout << 0 << " ";
        }
        std::cout << std::endl;
        return;
    }

    std::terminate();
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0