結果

問題 No.939 and or
ユーザー k_6101k_6101
提出日時 2019-12-05 01:47:42
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,681 bytes
コンパイル時間 3,146 ms
コンパイル使用メモリ 80,320 KB
実行使用メモリ 41,776 KB
最終ジャッジ日時 2024-05-08 18:45:10
合計ジャッジ時間 8,292 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,384 KB
testcase_01 AC 134 ms
41,300 KB
testcase_02 WA -
testcase_03 AC 136 ms
41,112 KB
testcase_04 AC 135 ms
41,220 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 135 ms
41,432 KB
testcase_10 AC 133 ms
41,436 KB
testcase_11 WA -
testcase_12 AC 135 ms
41,368 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 136 ms
41,096 KB
testcase_17 WA -
testcase_18 AC 133 ms
41,280 KB
testcase_19 AC 135 ms
41,536 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 136 ms
41,532 KB
testcase_23 AC 137 ms
41,480 KB
testcase_24 WA -
testcase_25 AC 131 ms
41,536 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    public void solve() {
    	int A = Integer.parseInt(sc.next());
    	int B = Integer.parseInt(sc.next());
    	if(A > B) {
    		out.println(0);
    		return;
    	}
    	char[] ca = Integer.toBinaryString(A).toCharArray();
    	char[] cb = Integer.toBinaryString(B).toCharArray();
    	int offset = cb.length - ca.length;
    	int cnt = -1, flg = 0;
    	if(ca[0] != cb[offset]) {
    		out.println(0);
    		return;
    	}
    	for (int i = 1; i < ca.length; i++) {
    		if(ca[i] == 1 && cb[i+offset] == 0) {
        		out.println(0);
        		return;
    		}
			if(flg == 0 && ca[i] != cb[i+offset]) {
				flg = 1;
			} else if(ca[i] != cb[i+offset]) {
				if(cnt == -1)	cnt = 2;
				else			cnt *= 2;
			}
		}
    	out.println(cnt);
    }
    // ==================================================================
}
0