結果

問題 No.939 and or
ユーザー htensaihtensai
提出日時 2020-01-18 19:21:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 2,210 ms
コンパイル使用メモリ 71,976 KB
実行使用メモリ 49,800 KB
最終ジャッジ日時 2023-09-10 09:55:03
合計ジャッジ時間 4,695 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,320 KB
testcase_01 AC 41 ms
49,496 KB
testcase_02 AC 42 ms
49,760 KB
testcase_03 AC 41 ms
49,440 KB
testcase_04 AC 41 ms
49,340 KB
testcase_05 AC 41 ms
49,436 KB
testcase_06 AC 41 ms
49,304 KB
testcase_07 AC 41 ms
49,244 KB
testcase_08 AC 41 ms
49,800 KB
testcase_09 AC 42 ms
49,500 KB
testcase_10 AC 41 ms
49,448 KB
testcase_11 AC 41 ms
49,456 KB
testcase_12 AC 42 ms
49,480 KB
testcase_13 AC 41 ms
49,404 KB
testcase_14 AC 41 ms
49,432 KB
testcase_15 AC 41 ms
49,624 KB
testcase_16 AC 42 ms
49,508 KB
testcase_17 AC 42 ms
49,308 KB
testcase_18 AC 41 ms
47,512 KB
testcase_19 AC 42 ms
49,424 KB
testcase_20 AC 41 ms
49,536 KB
testcase_21 AC 41 ms
49,496 KB
testcase_22 AC 42 ms
49,300 KB
testcase_23 AC 42 ms
49,316 KB
testcase_24 AC 42 ms
49,416 KB
testcase_25 AC 42 ms
49,480 KB
testcase_26 AC 42 ms
49,292 KB
testcase_27 AC 41 ms
49,524 KB
testcase_28 AC 42 ms
49,476 KB
testcase_29 AC 41 ms
49,512 KB
testcase_30 AC 42 ms
49,288 KB
testcase_31 AC 41 ms
49,500 KB
権限があれば一括ダウンロードができます

ソースコード

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