結果

問題 No.3057 A xor B = C
ユーザー root__786root__786
提出日時 2020-04-01 21:37:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 640 bytes
コンパイル時間 1,857 ms
コンパイル使用メモリ 199,272 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 17:03:46
合計ジャッジ時間 2,386 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll myXOR(ll x, ll y)
{
    ll res = 0; // Initialize result

    // Assuming 32-bit Integer
    for (ll i = 31; i >= 0; i--)
    {
        // Find current bits in x and y
        bool b1 = x & (1 << i);
        bool b2 = y & (1 << i);

        // If both are 1 then 0 else xor is same as OR
        bool xoredBit = (b1 & b2) ? 0 : (b1 | b2);

        // Update result
        res <<= 1;
        res |= xoredBit;
    }
    return res;
}

int main(){
    long long int  a=5,b=3;
    cin>>a>>b;
    long long int  c=(a|b)&(~a|~b);
    cout<<(myXOR(a,b))<<endl;
    return 0;
}
0