結果

問題 No.822 Bitwise AND
ユーザー Grenache
提出日時 2019-04-28 14:51:43
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 867 bytes
コンパイル時間 3,467 ms
コンパイル使用メモリ 74,616 KB
実行使用メモリ 54,524 KB
最終ジャッジ日時 2024-12-16 06:17:21
合計ジャッジ時間 6,700 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 3
権限があれば一括ダウンロードができます

ソースコード

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();

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