結果

問題 No.939 and or
ユーザー tentententen
提出日時 2023-08-01 13:59:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,985 bytes
コンパイル時間 2,180 ms
コンパイル使用メモリ 88,016 KB
実行使用メモリ 50,500 KB
最終ジャッジ日時 2024-04-19 13:18:33
合計ジャッジ時間 4,583 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
50,168 KB
testcase_01 AC 47 ms
50,380 KB
testcase_02 AC 45 ms
50,072 KB
testcase_03 AC 45 ms
50,436 KB
testcase_04 AC 45 ms
50,400 KB
testcase_05 AC 46 ms
50,292 KB
testcase_06 AC 46 ms
50,432 KB
testcase_07 AC 45 ms
50,484 KB
testcase_08 AC 47 ms
50,464 KB
testcase_09 AC 47 ms
50,412 KB
testcase_10 AC 45 ms
50,404 KB
testcase_11 AC 46 ms
50,440 KB
testcase_12 AC 48 ms
50,172 KB
testcase_13 AC 48 ms
50,156 KB
testcase_14 AC 47 ms
50,412 KB
testcase_15 AC 47 ms
50,328 KB
testcase_16 AC 45 ms
50,452 KB
testcase_17 AC 48 ms
50,396 KB
testcase_18 AC 48 ms
50,408 KB
testcase_19 AC 46 ms
50,500 KB
testcase_20 AC 47 ms
50,292 KB
testcase_21 AC 48 ms
50,440 KB
testcase_22 AC 46 ms
50,416 KB
testcase_23 AC 46 ms
50,276 KB
testcase_24 AC 46 ms
50,492 KB
testcase_25 AC 48 ms
50,256 KB
testcase_26 AC 48 ms
50,064 KB
testcase_27 AC 45 ms
50,088 KB
testcase_28 AC 45 ms
50,260 KB
testcase_29 AC 45 ms
50,420 KB
testcase_30 AC 46 ms
50,448 KB
testcase_31 AC 45 ms
50,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
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();
        if (a == b) {
            System.out.println(1);
            return;
        }
        int count = 0;
        while (a > 0 || b > 0) {
            if (a % 2 == 0) {
                if (b % 2 == 1) {
                    count++;
                }
            } else {
                if (b % 2 == 0) {
                    System.out.println(0);
                    return;
                }
            }
            a >>= 1;
            b >>= 1;
        }
        System.out.println(1 << (count - 1));
    }
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0