結果

問題 No.1450 nahco314's First Problem
ユーザー MZKiMZKi
提出日時 2021-03-31 15:47:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,599 bytes
コンパイル時間 2,825 ms
コンパイル使用メモリ 146,608 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-08 08:36:02
合計ジャッジ時間 3,432 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 3 ms
4,384 KB
testcase_20 AC 4 ms
4,384 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 4 ms
4,380 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 4 ms
4,380 KB
testcase_33 AC 3 ms
4,380 KB
testcase_34 AC 4 ms
4,376 KB
testcase_35 AC 4 ms
4,376 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 4 ms
4,376 KB
testcase_38 AC 3 ms
4,380 KB
testcase_39 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define eps (double)(1e-9)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

ll x;
ll solve(ll a, ll b){
    vector<int> v;
    for(ll i = 0; i <= 60; i++){
        if(i < 6){
            if(a & (1<<i))v.push_back(1);
            else v.push_back(0);
        }else{
            if(x & (1LL<<i)){
                v.push_back(1);
                a |= (1LL<<i);
            }else v.push_back(0);
        }
    }
    int acu = accumulate(all(v), 0);
    bool ok = true;
    if((a ^ b) != x)ok = false;
    else if(acu != b)ok = false;
    if(ok)return a;
    else return -1;
}

int main() {
    cin >> x;
    ll ans = -1;
    for(int bit1 = 0; bit1 < 64; bit1++){
        for(int bit2 = 0; bit2 < 64; bit2++){
            vector<int> n(10);
            vector<int> m(10);
            rep(i, 10){
                if(bit1 & (1<<i))n[i] = 0;
                else n[i] = 1;
                if(bit2 & (1<<i))m[i] = 0;
                else m[i] = 1;
            }
            ll now = solve(bit1, bit2);
            if(now != -1)ans = now;
        }
    }
    cout << ans << endl;
}
0