結果

問題 No.822 Bitwise AND
ユーザー kyort0nkyort0n
提出日時 2019-04-26 22:07:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,471 ms / 2,000 ms
コード長 926 bytes
コンパイル時間 2,713 ms
コンパイル使用メモリ 165,000 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 01:09:18
合計ジャッジ時間 15,993 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,467 ms
4,380 KB
testcase_01 AC 31 ms
4,380 KB
testcase_02 AC 14 ms
4,380 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 1,460 ms
4,380 KB
testcase_05 AC 710 ms
4,376 KB
testcase_06 AC 1,262 ms
4,380 KB
testcase_07 AC 1,449 ms
4,376 KB
testcase_08 AC 1,471 ms
4,376 KB
testcase_09 AC 1,240 ms
4,376 KB
testcase_10 AC 282 ms
4,376 KB
testcase_11 AC 301 ms
4,380 KB
testcase_12 AC 1,373 ms
4,376 KB
testcase_13 AC 16 ms
4,376 KB
testcase_14 AC 301 ms
4,380 KB
testcase_15 AC 786 ms
4,376 KB
testcase_16 AC 20 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    ll ans = 0;
    int val = 1;
    /*
    for(int i = 1; i <= 20; i++) {
        if(K >= val && val > N) {
            cout << "INF" << endl;
            return 0;
        }
        val *= 2;
    }
    */
    for(int y = 0; y <= 5000000; y++) {
        for(int k = 0; k <= K; k++) {
            int x = y - k;
            if(x < 0) continue;
            if((x&y) == N) {
                ans++;
                if(y >= 1000000) {
                    cout << "INF" << endl;
                    return 0;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0