結果

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

ソースコード

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(1L << (cnt - 1));
	}
}
0