結果

問題 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
コンパイル時間 504 ms
コンパイル使用メモリ 85,076 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-20 13:28:53
合計ジャッジ時間 2,376 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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