結果

問題 No.638 Sum of "not power of 2"
ユーザー siro53siro53
提出日時 2019-01-27 00:17:59
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,075 bytes
コンパイル時間 725 ms
コンパイル使用メモリ 77,232 KB
実行使用メモリ 814,392 KB
最終ジャッジ日時 2023-10-19 20:50:47
合計ジャッジ時間 3,537 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 MLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<ll, ll> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

ll n;

void input(){
    cin >> n;
}

bool check(ll x){
    while(x != 1){
        if (x % 2 == 1) return false;
        x /= 2;
    }
    return true;
} // 2の整数乗ならtrue、そうでないならfalse

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    vector<P> ab;
    for(ll a=1;a<n;a++){
        ab.push_back(P(a, n - a));
    }
    sort(ab.begin(), ab.end());
    for(ll i = 0; i < ab.size(); i++){
        if (check(ab[i].first) || check(ab[i].second)) continue;
        cout << ab[i].first << ' ' << ab[i].second << endl;
        return 0; 
    }
    cout << (-1) << endl;
    return 0;
}
0