結果

問題 No.638 Sum of "not power of 2"
ユーザー fushime2fushime2
提出日時 2018-01-26 23:18:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 906 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 143,180 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 18:12:40
合計ジャッジ時間 2,564 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }

ll n;
bool C(ll x) {
    ll a = 1;
    while (a <= x) {
        if (x == a) return true;
        a *= 2;
    }
    return false;
}

void solve(ll n) {
    for (ll i = 1; i <= n; i++) {
        if (i > n - i) break;
        if (!C(i) && !C(n - i)) {
            printf("%lld %lld\n", i, n - i);
            return;
        }
    }
    puts("-1");
}

int main() {
    //FOR(i, 1, 23) {
    //    solve(i);
    //}
    //solve(ll(1e18));
    ll n; cin >> n;
    solve(n);
    return 0;
}
0