結果

問題 No.688 E869120 and Constructing Array 2
ユーザー phsplsphspls
提出日時 2020-04-22 23:48:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,050 bytes
コンパイル時間 1,792 ms
コンパイル使用メモリ 165,936 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 13:45:06
合計ジャッジ時間 3,090 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main() {
    int k;
    cin >> k;
    int korg = k;
    if(k==0) {
        cout << 1 << endl;
        cout << 0 << endl;
        return 0;
    }

    int twices = 0;
    while(k % 2 == 0) {
        k /= 2;
        twices++;
    }
    vector<int> cands;
    for(int i=1; i<16; i++) {
        int val = i * (i+1) / 2;
        if(val % k == 0) {
            cands.push_back(i);
        }
    }
    for(int lowval: cands) {
        int val = lowval * (lowval+1) / 2;
        int rest = korg / val;
        int zeroval = 0;
        while(rest % 2 == 0) {
            rest /= 2;
            zeroval++;
        }
        if(lowval + 1 + zeroval <= 30) {
            cout << lowval + 1 + zeroval << "\n";
            rep(i, zeroval) cout << "0 ";
            rep(i, lowval+1) {
                cout << "1";
                if(i < lowval) cout << " ";
            }
            cout << "\n";
            return 0;
        }
    }
}
0