結果

問題 No.688 E869120 and Constructing Array 2
ユーザー mmn15277198mmn15277198
提出日時 2021-02-06 14:58:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 909 bytes
コンパイル時間 721 ms
コンパイル使用メモリ 75,180 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-15 22:08:05
合計ジャッジ時間 1,898 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
        }
    }
    
    int cnt_0 = 0 , cnt_1 = 0;
    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;
                cnt_1 = i;
                cnt_0 = j;
                break;
            }
        }
    }
    
    for(int i = 0; i < cnt_0; i++){
        cout << "0" << " ";
    }
    for(int i = 0; i < cnt_1; i++){
        cout << "1";
        if(i != cnt_1 - 1)cout << " ";
        else cout << endl;
    }
    
    return 0;
}
0