結果

問題 No.822 Bitwise AND
ユーザー ks2mks2m
提出日時 2021-03-04 23:08:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 446 bytes
コンパイル時間 2,296 ms
コンパイル使用メモリ 75,040 KB
実行使用メモリ 41,852 KB
最終ジャッジ日時 2024-04-15 14:50:10
合計ジャッジ時間 5,700 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 190 ms
41,392 KB
testcase_01 AC 137 ms
41,596 KB
testcase_02 AC 137 ms
41,428 KB
testcase_03 AC 135 ms
41,412 KB
testcase_04 AC 212 ms
41,248 KB
testcase_05 AC 169 ms
41,292 KB
testcase_06 AC 192 ms
41,192 KB
testcase_07 AC 212 ms
41,196 KB
testcase_08 AC 143 ms
41,388 KB
testcase_09 AC 143 ms
41,852 KB
testcase_10 AC 139 ms
41,316 KB
testcase_11 AC 134 ms
41,388 KB
testcase_12 AC 144 ms
41,256 KB
testcase_13 AC 135 ms
41,308 KB
testcase_14 AC 133 ms
41,508 KB
testcase_15 AC 179 ms
41,456 KB
testcase_16 AC 136 ms
41,152 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;
		for (int i = 0; i <= n * 2 + k; i++) {
			for (int j = i; j <= i + k; j++) {
				if ((i & j) == n) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}
0