結果

問題 No.822 Bitwise AND
ユーザー 37zigen37zigen
提出日時 2019-04-26 22:03:47
言語 Java19
(openjdk 21)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 2,473 ms
コンパイル使用メモリ 72,212 KB
実行使用メモリ 56,916 KB
最終ジャッジ日時 2023-09-08 01:08:32
合計ジャッジ時間 5,453 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
56,488 KB
testcase_01 AC 119 ms
56,060 KB
testcase_02 AC 121 ms
56,500 KB
testcase_03 AC 119 ms
56,424 KB
testcase_04 AC 136 ms
56,308 KB
testcase_05 AC 133 ms
55,856 KB
testcase_06 AC 139 ms
56,048 KB
testcase_07 AC 140 ms
55,784 KB
testcase_08 AC 124 ms
56,380 KB
testcase_09 AC 124 ms
55,964 KB
testcase_10 AC 126 ms
56,916 KB
testcase_11 AC 122 ms
56,428 KB
testcase_12 AC 124 ms
56,072 KB
testcase_13 AC 124 ms
56,388 KB
testcase_14 AC 123 ms
56,404 KB
testcase_15 AC 134 ms
56,048 KB
testcase_16 AC 121 ms
56,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	void run() throws Exception {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		if (N + 1 <= K) {
			System.out.println("INF");
			return;
		}
		int max = 1;
		while (max <= N)
			max *= 2;
		max -= 1;
		long ans = 0;
		for (long y = N; y <= max; ++y) {
			for (long x = Math.max(0, y - K); x <= y; ++x)
				if ((x & y) == N) {
					++ans;
				}
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0