結果

問題 No.822 Bitwise AND
ユーザー htensaihtensai
提出日時 2020-02-14 17:53:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 660 bytes
コンパイル時間 1,923 ms
コンパイル使用メモリ 71,200 KB
実行使用メモリ 50,048 KB
最終ジャッジ日時 2023-09-08 01:14:49
合計ジャッジ時間 3,707 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
49,784 KB
testcase_01 AC 41 ms
49,280 KB
testcase_02 AC 40 ms
49,328 KB
testcase_03 AC 41 ms
49,488 KB
testcase_04 AC 66 ms
50,048 KB
testcase_05 AC 62 ms
49,888 KB
testcase_06 AC 70 ms
49,976 KB
testcase_07 AC 65 ms
49,960 KB
testcase_08 AC 44 ms
49,196 KB
testcase_09 AC 41 ms
49,156 KB
testcase_10 AC 41 ms
49,296 KB
testcase_11 AC 40 ms
49,224 KB
testcase_12 AC 40 ms
49,416 KB
testcase_13 AC 41 ms
49,324 KB
testcase_14 AC 41 ms
47,268 KB
testcase_15 AC 60 ms
49,816 KB
testcase_16 AC 41 ms
49,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String[] first = br.readLine().split(" ", 2);
		int n = Integer.parseInt(first[0]);
		int k = Integer.parseInt(first[1]);
		if (n < k) {
		    System.out.println("INF");
		    return;
		}
		int max = 1;
		while (n >= max) {
		    max = max << 1;
		}
		int count = 0;
		for (int i = n; i <= max; i++) {
		    for (int j = i; j - i <= k; j++) {
		        if ((i & j) == n) {
		            count++;
		        }
		    }
		}
		System.out.println(count);
    }
}
0