結果
| 問題 |
No.822 Bitwise AND
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-26 22:03:47 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 163 ms / 2,000 ms |
| コード長 | 655 bytes |
| コンパイル時間 | 2,821 ms |
| コンパイル使用メモリ | 75,592 KB |
| 実行使用メモリ | 54,584 KB |
| 最終ジャッジ日時 | 2024-06-25 18:12:53 |
| 合計ジャッジ時間 | 6,142 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
new Main().run();
}
void run() throws Exception {
Scanner sc = new Scanner(System.in);
long N = sc.nextLong();
long K = sc.nextLong();
if (N + 1 <= K) {
System.out.println("INF");
return;
}
int max = 1;
while (max <= N)
max *= 2;
max -= 1;
long ans = 0;
for (long y = N; y <= max; ++y) {
for (long x = Math.max(0, y - K); x <= y; ++x)
if ((x & y) == N) {
++ans;
}
}
System.out.println(ans);
}
void tr(Object... objects) {
System.out.println(Arrays.deepToString(objects));
}
}