結果

問題 No.939 and or
ユーザー れいん
提出日時 2025-06-02 14:40:38
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 557 bytes
コンパイル時間 3,755 ms
コンパイル使用メモリ 272,380 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-02 14:40:43
合計ジャッジ時間 4,816 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    long long A, B;
    cin >> A >> B;
    if (A > B)
    {
        cout << 0;
        return 0;
    }
    if (A == B)
    {
        cout << 1;
        return 0;
    }
    long long ans = 1;
    for (int i = 0; i < 32; i++)
    {
        int A_i = (A >> i) & 1;
        int B_i = (B >> i) & 1;
        if (A_i == 1 && B_i == 0)
        {
            cout << 0;
            return 0;
        }
        if (A_i == 0 && B_i == 1)
        {
            ans *= 2;
        }
    }
    cout << ans / 2;
}
0