結果
| 問題 |
No.822 Bitwise AND
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-28 18:25:40 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 953 bytes |
| コンパイル時間 | 4,045 ms |
| コンパイル使用メモリ | 75,080 KB |
| 実行使用メモリ | 54,732 KB |
| 最終ジャッジ日時 | 2024-06-25 18:17:34 |
| 合計ジャッジ時間 | 7,318 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 1 |
ソースコード
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);
}
}
}