結果

問題 No.822 Bitwise AND
ユーザー 37zigen
提出日時 2019-04-26 22:01:52
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 668 bytes
コンパイル時間 2,098 ms
コンパイル使用メモリ 74,816 KB
実行使用メモリ 54,368 KB
最終ジャッジ日時 2024-11-25 03:47:17
合計ジャッジ時間 4,544 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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