結果

問題 No.939 and or
ユーザー tentententen
提出日時 2024-02-06 08:25:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 1,547 bytes
コンパイル時間 7,675 ms
コンパイル使用メモリ 78,012 KB
実行使用メモリ 54,012 KB
最終ジャッジ日時 2024-02-06 08:25:57
合計ジャッジ時間 6,054 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
53,976 KB
testcase_01 AC 52 ms
53,984 KB
testcase_02 AC 52 ms
53,972 KB
testcase_03 AC 53 ms
53,972 KB
testcase_04 AC 52 ms
53,992 KB
testcase_05 AC 51 ms
53,984 KB
testcase_06 AC 58 ms
54,008 KB
testcase_07 AC 53 ms
53,984 KB
testcase_08 AC 52 ms
53,996 KB
testcase_09 AC 53 ms
53,992 KB
testcase_10 AC 53 ms
53,976 KB
testcase_11 AC 54 ms
53,972 KB
testcase_12 AC 52 ms
53,976 KB
testcase_13 AC 53 ms
54,004 KB
testcase_14 AC 52 ms
51,992 KB
testcase_15 AC 53 ms
53,920 KB
testcase_16 AC 51 ms
53,972 KB
testcase_17 AC 53 ms
53,984 KB
testcase_18 AC 52 ms
53,980 KB
testcase_19 AC 51 ms
53,940 KB
testcase_20 AC 52 ms
53,984 KB
testcase_21 AC 52 ms
53,976 KB
testcase_22 AC 60 ms
53,964 KB
testcase_23 AC 53 ms
53,988 KB
testcase_24 AC 53 ms
53,984 KB
testcase_25 AC 52 ms
54,012 KB
testcase_26 AC 53 ms
53,964 KB
testcase_27 AC 53 ms
53,992 KB
testcase_28 AC 53 ms
53,972 KB
testcase_29 AC 54 ms
53,980 KB
testcase_30 AC 52 ms
53,980 KB
testcase_31 AC 53 ms
53,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        long ans = 1;
        for (int i = 0; i < 31; i++) {
            if ((a & (1 << i)) == 0) {
                if ((b & (1 << i)) > 0) {
                    ans *= 2;
                }
            } else {
                if ((b & (1 << i)) == 0) {
                    ans = 0;
                }
            }
        }
        if (ans > 1) {
            ans /= 2;
        }
        System.out.println(ans);
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0