結果

問題 No.688 E869120 and Constructing Array 2
ユーザー yosupotyosupot
提出日時 2018-05-18 23:28:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,278 bytes
コンパイル時間 911 ms
コンパイル使用メモリ 106,332 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 20:06:40
合計ジャッジ時間 1,731 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main() {
    ll k;
    cin >> k;
    if (k == 0) {
        //ここいる?
        cout << 1 << endl;
        cout << 0 << endl;
        return 0;
    }
    for (int n = 2; n <= 30; n++) {
        for (int a = 0; a <= n-2; a++) {
            int b = n-a;
            ll z = b*(b-1) / 2;
            for (int i = 0; i < a; i++) {
                z *= 2;
            }
            if (k == z) {
                cout << n << endl;
                for (int i = 0; i < a; i++) {
                    cout << 0 << " ";
                }
                for (int i = a; i < n; i++) {
                    cout << 1 << " ";
                }
                cout << endl;
            }
        }
    }
    return 0;
}
0