結果

問題 No.822 Bitwise AND
ユーザー GrenacheGrenache
提出日時 2019-04-28 18:23:20
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 924 bytes
コンパイル時間 3,322 ms
コンパイル使用メモリ 75,644 KB
実行使用メモリ 54,544 KB
最終ジャッジ日時 2024-05-09 22:37:58
合計ジャッジ時間 6,490 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 117 ms
52,856 KB
testcase_02 WA -
testcase_03 AC 127 ms
54,220 KB
testcase_04 AC 130 ms
54,352 KB
testcase_05 AC 131 ms
54,344 KB
testcase_06 AC 138 ms
54,468 KB
testcase_07 AC 130 ms
54,384 KB
testcase_08 AC 131 ms
54,544 KB
testcase_09 AC 131 ms
53,960 KB
testcase_10 AC 132 ms
54,432 KB
testcase_11 AC 117 ms
53,268 KB
testcase_12 AC 134 ms
54,112 KB
testcase_13 AC 129 ms
54,488 KB
testcase_14 AC 130 ms
54,028 KB
testcase_15 AC 132 ms
54,128 KB
testcase_16 AC 132 ms
53,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Scanner;


public class Main_yukicoder822 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();

		int max = n + (Integer.highestOneBit(n) << 1);
		if (max <= (Integer.highestOneBit(n) << 1) - 1 + k || (n == 0 && k == 0)) {
			pr.println("INF");
		} else {
			int ans = 0;
			for (int x = n; x <= n + k; x++) {
//				if ((x & n) != n) {
//					continue;
//				}
				
				for (int y = x; y <= x + k; y++) {
					if ((x & y) == n) {
						ans++;
					}
				}
			}
			
			pr.println(ans);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0