結果

問題 No.939 and or
ユーザー htensai
提出日時 2020-01-18 19:21:37
言語 Java
(openjdk 23)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 74,320 KB
実行使用メモリ 37,280 KB
最終ジャッジ日時 2024-06-28 01:22:17
合計ジャッジ時間 5,016 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ", 2);
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        if ((a & b) != a) {
            System.out.println(0);
            return;
        }
        int count = 0;
        int c = b - a;
        if (c == 0) {
            System.out.println(1);
            return;
        }
        while (c > 0) {
            count += c % 2;
            c /= 2;
        }
        System.out.println((long)(Math.pow(2, count - 1)));
    }
}
0