結果
問題 |
No.822 Bitwise AND
|
ユーザー |
|
提出日時 | 2019-04-28 18:23:20 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 924 bytes |
コンパイル時間 | 3,533 ms |
コンパイル使用メモリ | 75,740 KB |
実行使用メモリ | 54,304 KB |
最終ジャッジ日時 | 2024-12-17 17:09:23 |
合計ジャッジ時間 | 6,337 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 2 |
ソースコード
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 || (n == 0 && k == 0)) { 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); } } }