結果

問題 No.688 E869120 and Constructing Array 2
ユーザー 👑 rin204rin204
提出日時 2020-11-25 18:35:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 689 bytes
コンパイル時間 1,499 ms
コンパイル使用メモリ 166,232 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-01 01:50:47
合計ジャッジ時間 4,709 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 TLE -
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘std::vector<int> zero_one(ll)’ 内:
main.cpp:19:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   19 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<int> zero_one(ll k){
    ll zero = 1;
    for(int i = 0; i <= 30; i++){
        for(int j = 2; i + j <= 30; j++){
            ll tmp = j * (j - 1) / 2;
            if(tmp * zero == k){
                vector<int> ret(2);
                ret.at(0) = i;
                ret.at(1) = j;
                return ret;
            }
        }
        zero *= 2;
    }
}

int main(void){
    ll k;
    cin >> k;
    auto ans = zero_one(k);
    cout << ans.at(0) + ans.at(1) << endl;
    for(int i = 0; i < ans.at(0); i++) cout << 0 << " ";
    for(int i = 0; i < ans.at(1); i++) cout << 1 << " ";
    cout << endl;
    
}
0