結果

問題 No.939 and or
ユーザー stone_725
提出日時 2019-12-02 00:24:50
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 379 bytes
コンパイル時間 574 ms
コンパイル使用メモリ 120,832 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 15:41:36
合計ジャッジ時間 1,666 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 24 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
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