結果

問題 No.939 and or
ユーザー htensai
提出日時 2019-12-09 11:31:57
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 684 bytes
コンパイル時間 2,389 ms
コンパイル使用メモリ 74,208 KB
実行使用メモリ 56,080 KB
最終ジャッジ日時 2024-06-12 22:48:29
合計ジャッジ時間 7,401 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int count = 0;
        while (a > 0 && b > 0) {
            int aa = a % 2;
            int bb = b % 2;
            if (aa == 0 && bb == 1) {
                count++;
            } else if (aa == 1 && bb == 0) {
                count = 0;
                break;
            }
            a /= 2;
            b /= 2;
        }
        if (count == 0) {
            System.out.println(0);
        } else {
            System.out.println((long)(Math.pow(2, count - 1)));
        }
    }
}
0