結果

問題 No.939 and or
ユーザー stone_725stone_725
提出日時 2019-12-02 00:24:50
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 379 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 119,880 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-07 19:59:51
合計ジャッジ時間 1,562 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 WA -
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 1 ms
6,944 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 WA -
testcase_31 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:10: warning: self-comparison always evaluates to false [-Wtautological-compare]
    8 |     if(a != a & b){
      |          ^
main.cpp:8:15: warning: & has lower precedence than !=; != will be evaluated first [-Wparentheses]
    8 |     if(a != a & b){
      |        ~~~~~~~^
main.cpp:8:15: note: place parentheses around the '!=' expression to silence this warning
    8 |     if(a != a & b){
      |               ^
      |        (     )
main.cpp:8:15: note: place parentheses around the & expression to evaluate it first
    8 |     if(a != a & b){
      |               ^  
      |             (    )
2 warnings generated.

ソースコード

diff #

#include <iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a != a & b){
        cout << 0 << "\n";
        return 0;
    }
    if(a == b){
        cout << 1 << "\n";
        return 0;
    }
    int c = a ^ b;
    int ans = 1;
    while(c){
        if(c % 2){
            ans *= 2;
        }
        c /= 2;
    }
    cout << ans / 2 << "\n";
}
0