結果

問題 No.1298 OR XOR
ユーザー Prateek GautamPrateek Gautam
提出日時 2020-11-27 23:21:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 752 bytes
コンパイル時間 1,508 ms
コンパイル使用メモリ 164,996 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-10 21:44:36
合計ジャッジ時間 3,111 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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