結果

問題 No.822 Bitwise AND
ユーザー IKyoproIKyopro
提出日時 2019-04-26 22:06:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 497 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 58,796 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-03 22:42:52
合計ジャッジ時間 1,466 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <cassert>
using namespace std;

int N,K;
int main(){
    cin >> N >> K;
    int ma = -1;
    for(int i=0;i<30;i++) if(N&(1<<i)) ma = i;
    if(K>=(1<<(ma+1))){
        cout << "INF" << endl;
        return 0;
    }
    int a = ceil(log2(K));
    int ans = 0;
    for(int i=0;i<=N+(1<<(a+2));i++){
        for(int j=0;j<=K;j++){
//            cerr << (i & (i+j)) << endl;
            if((i & (i+j))==N) ans++;
        }
    }
    cout << ans << endl;
}
0