結果

問題 No.822 Bitwise AND
ユーザー treeonetreeone
提出日時 2019-04-26 21:47:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,092 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 197,608 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 01:08:00
合計ジャッジ時間 3,210 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 62 ms
4,376 KB
testcase_05 AC 31 ms
4,376 KB
testcase_06 AC 55 ms
4,380 KB
testcase_07 AC 61 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 35 ms
4,380 KB
testcase_16 AC 1 ms
4,380 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 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 + 1; 
            break;
        }
    }
    for(int i = 0; i < (1LL << msbn); i++){
        for(int j = i; j <= i + k; j++){
            if((i & j) == n){
                ans++;
                int msbj = 0;
                for(int l = 0; l < 20; l++){
                    if(j <= (1LL << l)){
                        msbj = l + 1; 
                        break;
                    }
                }
                if(msbj > msbn){
                    cout << "INF" << endl;
                    return 0;
                }
            }
        }
    }
    cout << ans << endl;
}
0