結果

問題 No.688 E869120 and Constructing Array 2
ユーザー mmn15277198
提出日時 2021-02-06 15:03:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 907 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 74,240 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 23:35:54
合計ジャッジ時間 1,373 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

const int sz = 35;

int main(){
    ll k;
    cin >> k;
    vector<vector<ll>> a(sz , vector<ll>(sz , 0));
    
    for(int i = 1; i < sz; i++){
        a[i][0] = (ll)i * (i - 1) / (ll)2;
        for(int j = 1; j < sz; j++){
            a[i][j] = a[i][j - 1] * (ll)2;
        }
    }
    
    for(int i = 1; i < sz; i++){
        for(int j = 0; j < sz; j++){
            if(a[i][j] == k && i + j <= 30){
                cout << i + j << endl;
                for(int x = 0; x < i; x++){
                    cout << "1" << " ";
                }  
                for(int x = 0; x < j; x++){
                    cout << "0";
                    if(x != j - 1)cout << " ";
                    else cout << endl;
                }
                exit(0);
            }
        }
    }
    
    return 0;
}
0