結果

問題 No.822 Bitwise AND
ユーザー treeonetreeone
提出日時 2019-04-26 21:41:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 719 bytes
コンパイル時間 1,945 ms
コンパイル使用メモリ 197,644 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-16 13:24:07
合計ジャッジ時間 3,124 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 32 ms
4,380 KB
testcase_05 AC 18 ms
4,376 KB
testcase_06 AC 29 ms
4,376 KB
testcase_07 AC 32 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 19 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int msbn = 64 - __builtin_clzll(n);
    int ans = 0;
    for(int i = 0; i < (1LL << msbn); i++){
        for(int j = i; j <= i + k; j++){
            int msbj = 64 - __builtin_clzll(j);
            if((i & j) == n){
                ans++;
                if(msbj > msbn){
                    cout << "INF" << endl;
                    return 0;
                }
            }
        }
    }
    cout << ans << endl;
}
0