結果

問題 No.822 Bitwise AND
ユーザー SugarDragon5SugarDragon5
提出日時 2019-04-26 22:27:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,972 bytes
コンパイル時間 1,729 ms
コンパイル使用メモリ 165,852 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2024-05-03 23:34:39
合計ジャッジ時間 8,172 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int lg2(int x){
    int res=0;
    while(x){
        x>>=1;
        res++;
    }
    return res;
}
bool inf(int n,int m){
    int b=0;
    int k=1;
    while(n){
        if(n%2==0){
            b+=k;
        }
        k*=2;
    }
    if(k-b<=m){
        return true;
    }
    return false;
}
int main(){
    int n,m;
    cin>>n>>m;
    if(!n){
        if(m){
            cout<<"INF"<<endl;
        }else{
            cout<<1<<endl;
        }
        return 0;
    }
    if(inf(n,m)){
        cout<<"INF"<<endl;
        return 0;
    }
    int l=lg2(n);
    int ans=0;
    FOR(i,n,1<<(l+2)){
        if((i&n)!=n){
            continue;
        }
        REP(j,m+1){
            if((i&(i+j))==n){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}
0