結果

問題 No.688 E869120 and Constructing Array 2
ユーザー nukachanukacha
提出日時 2018-05-22 12:52:41
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 952 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 118,272 KB
実行使用メモリ 6,940 KB
最終ジャッジ日時 2024-04-23 14:29:42
合計ジャッジ時間 1,341 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>

using namespace std;

long long K;

long long pow2(long long p) {
    long long r = 1;
    for (long long i = 0; i < p; i++) {
        r *= 2;
    }
    return r;
}

int main(int argc, char const *argv[])
{
    // (0の数**2) * (1の数 C 2) == K
    cin >> K;
    long long sizeb, nzero;
    for (sizeb = 2; sizeb <= 30; sizeb++) {
        bool bf = false;
        for (nzero = 0; nzero <= sizeb - 2; nzero++) {
            if (pow2(nzero) * (sizeb - nzero) * (sizeb - nzero - 1) / 2 == K) {
                bf = true;
                break;
            }
        }
        if (bf) {
            break;
        }
    }
    cout << sizeb << endl;
    for (long long i = 0; i < nzero; i++) {
        cout << "0 ";
    }
    for (long long i = 0; i < sizeb - nzero; i++) {
        cout << "1";
        if (i != sizeb - nzero - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
    return 0;
}
0