結果

問題 No.939 and or
ユーザー tentententen
提出日時 2020-08-26 17:36:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 2,140 ms
コンパイル使用メモリ 74,820 KB
実行使用メモリ 41,692 KB
最終ジャッジ日時 2024-04-25 03:30:55
合計ジャッジ時間 7,067 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
40,848 KB
testcase_01 AC 115 ms
41,308 KB
testcase_02 AC 104 ms
40,172 KB
testcase_03 AC 112 ms
40,096 KB
testcase_04 AC 110 ms
40,388 KB
testcase_05 AC 120 ms
41,200 KB
testcase_06 AC 104 ms
40,744 KB
testcase_07 AC 112 ms
41,196 KB
testcase_08 AC 100 ms
39,832 KB
testcase_09 AC 112 ms
41,192 KB
testcase_10 AC 114 ms
41,256 KB
testcase_11 AC 103 ms
40,200 KB
testcase_12 AC 101 ms
39,992 KB
testcase_13 AC 114 ms
41,404 KB
testcase_14 AC 99 ms
40,008 KB
testcase_15 AC 109 ms
40,880 KB
testcase_16 AC 116 ms
41,496 KB
testcase_17 AC 112 ms
41,560 KB
testcase_18 AC 109 ms
41,552 KB
testcase_19 AC 99 ms
40,204 KB
testcase_20 AC 115 ms
41,692 KB
testcase_21 AC 109 ms
41,456 KB
testcase_22 AC 98 ms
39,936 KB
testcase_23 AC 106 ms
41,404 KB
testcase_24 AC 104 ms
39,840 KB
testcase_25 AC 100 ms
40,112 KB
testcase_26 AC 97 ms
40,308 KB
testcase_27 AC 101 ms
40,344 KB
testcase_28 AC 114 ms
41,368 KB
testcase_29 AC 107 ms
41,292 KB
testcase_30 AC 103 ms
40,564 KB
testcase_31 AC 110 ms
41,232 KB
権限があれば一括ダウンロードができます

ソースコード

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();
        if (a == b) {
            System.out.println(1);
            return;
        } else if ((a & b) != a) {
            System.out.println(0);
            return;
        }
        int c = b - a;
        int count = 0;
        while (c > 0) {
            count += c % 2;
            c /= 2;
        }
        System.out.println(1 << (count - 1));
    }
}
0