結果

問題 No.1298 OR XOR
ユーザー altair_kyoproaltair_kyopro
提出日時 2020-11-27 21:43:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,223 bytes
コンパイル時間 1,498 ms
コンパイル使用メモリ 164,656 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-01 05:11:27
合計ジャッジ時間 2,429 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

template<class T> bool chmin(T &a, T b) {if(a>b){a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b){a=b;return 1;}return 0;}
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll n;
    cin >> n;

    bitset<32> bit(n);

    ll count = 0;

    for (ll i = 0; i < 31; i++){
        if (bit.test(i)){
            count++;
        }
    }

    if (count <= 1){
        cout << -1 << " " << -1 << " " << -1 << endl;
        return 0;
    }

    ll a = 0,b = 0,c = 0;
    ll t = 1;
    bool x = true;

    for (ll i = 0; i < 31; i++){
        if (bit.test(i)){
            a += t;
            if (x) b += t;
            else c += t;
            x = !x;
        }
        t *= 2;
    }

    cout << a << " " << b << " " << c << endl;
}
0