結果

問題 No.1298 OR XOR
ユーザー Prateek Gautam
提出日時 2020-11-27 23:21:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 752 bytes
コンパイル時間 1,563 ms
コンパイル使用メモリ 167,876 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-13 01:02:21
合計ジャッジ時間 2,635 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    int count=0;
    for(int i=0; i<31; i++){
        if((1<<i)&n){
            count++;
        }
    }   

    if(count&1) cout<<(-1)<<' '<<(-1)<<' '<<(-1)<<'\n';
    else{
        int div=count/2;
        int a=0,b=0,c=n,i=0;
        while(i<31 && div>0){
            if((1<<i)&n){
                a+=(1<<i);
                div--;
            }
            i++;
        }
        div=count/2;
        while(i<31 && div>0){
            if((1<<i)&n){
                b+=(1<<i);
                div--;
            }
            i++;
        }
        cout<<a<<' '<<b<<' '<<c<<'\n';
    }

    return 0;
}
0