結果

問題 No.822 Bitwise AND
コンテスト
ユーザー Grenache
提出日時 2019-04-28 18:23:20
言語 Java
(openjdk 27 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
WA  
実行時間 -
コード長 924 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,574 ms
コンパイル使用メモリ 86,052 KB
実行使用メモリ 45,408 KB
最終ジャッジ日時 2026-10-04 17:59:01
合計ジャッジ時間 4,969 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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