結果

問題 No.638 Sum of "not power of 2"
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-03-23 21:02:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 488 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 77,320 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 22:49:16
合計ジャッジ時間 1,581 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<set>

typedef long long ll;

int main(int argc, char const *argv[]) {
    ll n;
    std::cin >> n;

    std::set<ll> s;
    for (ll x = 0; ; x++) {
        ll t = 1LL << x;
        if (n < t) break;
        s.insert(t);
    }

    for (ll a = 1; a < n; a++) {
        ll b = n - a;
        if (s.count(a) == 0 && s.count(b) == 0) {
            std::cout << a << " " << b << std::endl;
            return 0;
        }
    }

    std::cout << -1 << std::endl;
}
0