結果

問題 No.822 Bitwise AND
ユーザー ks2mks2m
提出日時 2019-04-26 23:21:22
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 480 bytes
コンパイル時間 2,081 ms
コンパイル使用メモリ 72,060 KB
実行使用メモリ 56,344 KB
最終ジャッジ日時 2023-09-08 01:12:18
合計ジャッジ時間 5,105 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 122 ms
55,768 KB
testcase_02 AC 123 ms
56,076 KB
testcase_03 AC 125 ms
55,632 KB
testcase_04 AC 127 ms
56,232 KB
testcase_05 AC 123 ms
56,072 KB
testcase_06 AC 125 ms
55,936 KB
testcase_07 AC 126 ms
55,984 KB
testcase_08 AC 126 ms
56,080 KB
testcase_09 AC 127 ms
56,324 KB
testcase_10 AC 122 ms
56,004 KB
testcase_11 AC 123 ms
55,560 KB
testcase_12 AC 126 ms
56,084 KB
testcase_13 AC 121 ms
55,784 KB
testcase_14 AC 124 ms
56,016 KB
testcase_15 AC 123 ms
56,236 KB
testcase_16 AC 124 ms
56,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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;
		}

		int ans = 0;
		int start = Math.max(n - k, 0);
		for (int i = start; i <= n + k; i++) {
			for (int j = i; j <= i + k; j++) {
				if ((i & j) == n) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}
0