結果

問題 No.939 and or
ユーザー ks2m
提出日時 2019-12-03 00:09:51
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 428 bytes
コンパイル時間 1,830 ms
コンパイル使用メモリ 74,616 KB
実行使用メモリ 56,140 KB
最終ジャッジ日時 2024-11-25 02:07:25
合計ジャッジ時間 6,200 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		if ((a & b) != a) {
			System.out.println(0);
			return;
		}

		int c = b - a;
		int cnt = 0;
		for (int i = 0; i < 32; i++) {
			if ((c >> i & 1) == 1) {
				cnt++;
			}
		}
		System.out.println(1 << (cnt - 1));
	}
}
0