結果
問題 | No.822 Bitwise AND |
ユーザー |
|
提出日時 | 2019-04-26 21:57:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 2,000 ms |
コード長 | 661 bytes |
コンパイル時間 | 1,707 ms |
コンパイル使用メモリ | 166,544 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 18:12:39 |
合計ジャッジ時間 | 2,591 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; bool judgeINF(int n, int K) { return n + 1 <= K; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, K; cin >> n >> K; if (judgeINF(n, K)) { cout << "INF" << endl; return 0; } int idx = -1; for (int i = 0; i <= 20; i++) { if (n & (1 << i)) { idx = i; } } idx++; int lim = (1 << idx) - 1; ll ans = 0; for (int y = n; y <= lim; y++) { for (int x = max(y - K, 0); x <= y; x++) { if ((x & y) == n) ans++; } } cout << ans << endl; return 0; }