結果

問題 No.822 Bitwise AND
ユーザー GrenacheGrenache
提出日時 2019-04-28 18:25:40
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 953 bytes
コンパイル時間 4,399 ms
コンパイル使用メモリ 72,956 KB
実行使用メモリ 56,360 KB
最終ジャッジ日時 2023-09-08 01:13:28
合計ジャッジ時間 6,169 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 119 ms
55,680 KB
testcase_02 AC 120 ms
56,360 KB
testcase_03 AC 117 ms
56,224 KB
testcase_04 AC 120 ms
55,428 KB
testcase_05 AC 121 ms
56,188 KB
testcase_06 AC 118 ms
55,888 KB
testcase_07 AC 121 ms
55,692 KB
testcase_08 AC 119 ms
56,164 KB
testcase_09 AC 122 ms
55,632 KB
testcase_10 AC 122 ms
56,152 KB
testcase_11 AC 119 ms
56,172 KB
testcase_12 AC 116 ms
55,664 KB
testcase_13 AC 115 ms
56,284 KB
testcase_14 AC 112 ms
56,048 KB
testcase_15 AC 122 ms
55,676 KB
testcase_16 AC 113 ms
55,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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) {
			pr.println("INF");
		} else if (n == 0 && k == 0) {
			pr.println(1);
		} 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