結果

問題 No.1298 OR XOR
ユーザー Kalyan GandhapuKalyan Gandhapu
提出日時 2020-11-27 23:10:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 950 bytes
コンパイル時間 1,888 ms
コンパイル使用メモリ 198,852 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-09 21:04:32
合計ジャッジ時間 3,228 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

	// author : kalyan
	#include "bits/stdc++.h"
	#define ll long long
	#define endl '\n'
	#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
	using namespace std;


	void solve(){
	    ll n;
	    cin >> n;
	    ll cnt = __builtin_popcount(n);
	    // debug(cnt);
	    if(cnt%2 == 0){
	    	ll b = 0,c = 0;
	    	bool ok = false;
	  		ll count = 0;
	    	for(ll i = 31; i >= 0; i--){
	    		ll k = n >> i;
	    		if(k&1){
	    			if(!ok){
	    				count++;
	    				b += pow(2,i);
	    				if(count == cnt/2)
	    					ok = true;
	    			}
	    			else{	
	    				c += pow(2,i);
	    			}
	    		}
	    	}
	    	cout << n << " " << b << " " << c << endl;
	    }
	    else{
	    	cout << "-1 -1 -1\n";
	    }
	    
	}  


	int main(){
	    fastio;
	    ll t;
	    t = 1;
	    // cin >> t;
	    // ll i = 1;
	    while(t--){
	        // cout << "Case #" << i << ": ";
	        solve();
	        // i++;
	    }
	    return 0;
	}
0