結果

問題 No.939 and or
ユーザー htensaihtensai
提出日時 2019-12-18 14:12:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,205 bytes
コンパイル時間 2,103 ms
コンパイル使用メモリ 73,644 KB
実行使用メモリ 51,760 KB
最終ジャッジ日時 2023-09-20 14:59:02
合計ジャッジ時間 5,274 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,440 KB
testcase_01 AC 42 ms
49,344 KB
testcase_02 WA -
testcase_03 AC 41 ms
49,488 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 42 ms
49,320 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 42 ms
49,440 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 42 ms
49,408 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 43 ms
49,280 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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[] first = br.readLine().split(" ", 2);
        int a = Integer.parseInt(first[0]);
        int b = Integer.parseInt(first[1]);
        if ((a & b) != a) {
            System.out.println(0);
            return;
        }
        int x = a ^ b;
        int count = 0;
        while (x > 0) {
            if (x % 2 == 1) {
                count++;
            }
            x /= 2;
        }
        long[][] comb = new long[count][count];
        for (int i = 0; i < count; i++) {
            for (int j = 0; j <= i; j++) {
                if (j == 0 || j == i) {
                    comb[i][j] = 1;
                } else {
                    comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
                }
            }
        }
        long total = 0;
        for (int i = 1; i < count; i++) {
            int base = count - i;
            for (int j = 0; j <= base; j++) {
                total += comb[base][j];
            }
        }
        System.out.println(total);
    }
}
0