結果

問題 No.822 Bitwise AND
ユーザー 37zigen37zigen
提出日時 2019-04-26 22:01:52
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 668 bytes
コンパイル時間 3,580 ms
コンパイル使用メモリ 71,668 KB
実行使用メモリ 56,312 KB
最終ジャッジ日時 2023-08-16 14:16:29
合計ジャッジ時間 5,740 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 119 ms
55,552 KB
testcase_02 AC 120 ms
55,848 KB
testcase_03 AC 120 ms
55,760 KB
testcase_04 AC 139 ms
55,920 KB
testcase_05 AC 137 ms
56,312 KB
testcase_06 AC 146 ms
55,764 KB
testcase_07 AC 141 ms
55,676 KB
testcase_08 AC 128 ms
55,696 KB
testcase_09 AC 121 ms
55,892 KB
testcase_10 AC 121 ms
55,420 KB
testcase_11 AC 121 ms
55,952 KB
testcase_12 AC 120 ms
55,900 KB
testcase_13 AC 122 ms
55,592 KB
testcase_14 AC 121 ms
55,644 KB
testcase_15 AC 134 ms
55,768 KB
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

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 (y - x <= K && (x & y) == N) {
					++ans;
				}
		}
		System.out.println(ans);
	}

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

}
0