結果

問題 No.822 Bitwise AND
ユーザー ks2m
提出日時 2019-04-26 22:16:44
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 696 bytes
コンパイル時間 1,920 ms
コンパイル使用メモリ 75,304 KB
実行使用メモリ 54,792 KB
最終ジャッジ日時 2024-11-25 04:35:16
合計ジャッジ時間 4,526 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		if (n < k) {
			System.out.println("INF");
			return;
		}

		Set<Integer> set = new HashSet<Integer>();
		for (int i = n; i <= n + k; i++) {
			if ((n & i) == n) {
				set.add(i);
			}
		}

		int ans = 0;
		Integer[] array = set.toArray(new Integer[0]);
		for (int i = 0; i < array.length; i++) {
			for (int j = i; j < array.length; j++) {
				if ((array[i] & array[j]) == n) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}
0