結果

問題 No.939 and or
ユーザー k_6101k_6101
提出日時 2019-12-05 02:14:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,675 bytes
コンパイル時間 2,154 ms
コンパイル使用メモリ 80,380 KB
実行使用メモリ 41,384 KB
最終ジャッジ日時 2024-05-08 21:20:45
合計ジャッジ時間 6,529 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
39,968 KB
testcase_01 AC 113 ms
41,212 KB
testcase_02 WA -
testcase_03 AC 102 ms
39,904 KB
testcase_04 AC 107 ms
40,332 KB
testcase_05 AC 98 ms
40,188 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 109 ms
41,264 KB
testcase_09 AC 111 ms
41,208 KB
testcase_10 AC 108 ms
40,848 KB
testcase_11 WA -
testcase_12 AC 113 ms
41,384 KB
testcase_13 AC 100 ms
39,900 KB
testcase_14 AC 97 ms
40,008 KB
testcase_15 AC 112 ms
41,112 KB
testcase_16 AC 97 ms
40,160 KB
testcase_17 WA -
testcase_18 AC 107 ms
40,140 KB
testcase_19 AC 105 ms
41,056 KB
testcase_20 AC 112 ms
40,984 KB
testcase_21 WA -
testcase_22 AC 109 ms
41,304 KB
testcase_23 AC 117 ms
40,064 KB
testcase_24 WA -
testcase_25 AC 101 ms
39,892 KB
testcase_26 WA -
testcase_27 AC 99 ms
40,212 KB
testcase_28 AC 111 ms
40,296 KB
testcase_29 AC 109 ms
41,140 KB
testcase_30 WA -
testcase_31 AC 109 ms
40,116 KB
権限があれば一括ダウンロードができます

ソースコード

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;
    	if(ca[0] != cb[offset]) {
    		out.println(0);
    		return;
    	}
    	int cnt = 1, flg = 0;
    	if(offset > 0)	flg = 1;
    	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]) {
				cnt *= 2;
			}
		}
    	out.println(cnt);
    }
    // ==================================================================
}
0