結果

問題 No.822 Bitwise AND
ユーザー treeonetreeone
提出日時 2019-04-26 21:45:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 726 bytes
コンパイル時間 1,948 ms
コンパイル使用メモリ 199,392 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 13:47:51
合計ジャッジ時間 2,978 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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 ans = 0;
    if(n == 0 && k == 1){
        cout << "INF" << endl;
        return 0;
    }
    int msbn = 0;
    for(int i = 0; i < 20; i++){
        if(n <= (1LL << i)){
            msbn = i; 
            break;
        }
    }
    for(int i = 0; i < (1LL << msbn); i++){
        for(int j = i; j <= i + k; j++){
            if((i & j) == n){
                ans++;
            }
        }
    }
    cout << ans << endl;
}
0