結果

問題 No.688 E869120 and Constructing Array 2
ユーザー rogi52
提出日時 2022-10-04 21:53:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 648 bytes
コンパイル時間 1,838 ms
コンパイル使用メモリ 192,228 KB
最終ジャッジ日時 2025-02-07 21:25:32
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int K; cin >> K;
    // c1 + c0 = N
    // c1 * (c1 - 1) / 2 * 2^{c0} = K
    for(int c1 = 0; c1 <= 30; c1++) {
        for(int c0 = 0; c0 <= 30; c0++) {
            int N = c1 + c0;
            if(1 <= N && N <= 30 && 1LL * c1 * (c1 - 1) / 2 * (1LL << c0) == K) {
                cout << N << endl;
                rep(_,c1) cout << "1 ";
                rep(_,c0) cout << "0 ";
                cout << endl;
                return 0;
            }
        }
    }
}
0