結果

問題 No.688 E869120 and Constructing Array 2
ユーザー sahiyasahiya
提出日時 2020-12-10 20:52:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,384 bytes
コンパイル時間 1,656 ms
コンパイル使用メモリ 112,748 KB
実行使用メモリ 8,736 KB
最終ジャッジ日時 2023-10-20 00:52:31
合計ジャッジ時間 5,986 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:66:22: warning: 'n' may be used uninitialized [-Wmaybe-uninitialized]
   66 |     cout << string(N - n, '1') + string(n, '0') << "\n";
      |                    ~~^~~
main.cpp:47:12: note: 'n' was declared here
   47 |     int N, n;
      |            ^
main.cpp:66:22: warning: 'N' may be used uninitialized [-Wmaybe-uninitialized]
   66 |     cout << string(N - n, '1') + string(n, '0') << "\n";
      |                    ~~^~~
main.cpp:47:9: note: 'N' was declared here
   47 |     int N, n;
      |         ^

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int K;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> K;

    int d = 0, x = K;
    while (x % 2 == 0) {
        d++;
        x >>= 1;
    }
    int N, n;
    for (int i = 0; i <= d; i++) {
        for (int j = 1; j * j <= (K >> i); j++) {
            if (((K >> i) % j == 0) && (j * (j + 1) == (K >> i)) && i + j + 2 <= 30) {
                N = i + j + 2;
                n = i + 1;
            }
        }
    }
    //cout << "N = " << N << ", n = " << n << "\n";

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */
    cout << N << "\n";
    cout << string(N - n, '1') + string(n, '0') << "\n";

    return 0;
}
0