結果
| 問題 |
No.822 Bitwise AND
|
| コンテスト | |
| ユーザー |
jell
|
| 提出日時 | 2019-07-09 15:31:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 2,477 bytes |
| コンパイル時間 | 1,972 ms |
| コンパイル使用メモリ | 176,072 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-25 18:17:49 |
| 合計ジャッジ時間 | 2,817 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using i64=int_fast64_t;
using pii=pair<int,int>;
using pll=pair<i64,i64>;
template <class T> constexpr T inf=numeric_limits<T>::max() / (T)2;
template <class T> using heap=priority_queue<T>;
template <class T> using minheap=priority_queue<T,vector<T>,greater<T>>;
#define fir first
#define sec second
#define mkp make_pair
#define mkt make_tuple
#define emb emplace_back
#define emp emplace
#define all(v) begin(v),end(v)
namespace std {
template <class T> void hash_combine(size_t &seed, T const &key) {
seed ^= hash<T>()(key) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
template <class T, class U> struct hash<pair<T,U>> {
size_t operator()(pair<T,U> const &pr) const
{
size_t seed = 0;
hash_combine(seed,pr.first);
hash_combine(seed,pr.second);
return seed;
}
};
}
void ios_untie() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
void file_setup() {
if(!freopen("stderr.txt","wt",stderr)) {
std::cerr << "Failed to open the stderr file\n";
freopen("CON","wt",stderr);
}
if(!freopen("stdout.txt","wt",stdout)) {
std::cerr << "Failed to open the stdout file\n";
freopen("CON","wt",stdout);
}
if(!freopen("stdin.txt","rt",stdin)) {
std::cerr << "Failed to open the stdin file.\n";
freopen("CON","rt",stdin);
}
}
template <class A, size_t N, class T> void init(A (&array)[N], const T &val) { fill((T*)array,(T*)(array + N),val); }
i64 binry(i64 ok, i64 ng, const function<bool(i64)> &f) {
while(abs(ok-ng)>1) {
i64 mid=(ok+ng)/2;
(f(mid) ? ok : ng) = mid;
}
return ok;
}
/*-------------------------------*/
int n,k;
int ans;
void solve() {
if(!n) {
if(k) cout<<"INF\n";
else cout<<"1\n";
return;
}
int t=1;
while(t<=n) t<<=1;
if(t>k) {
bool flag=false;
for(int x=n; x<t; ++x) {
for(int y=x; y<=x+k; ++y) {
if((x&y)==n) {
++ans;
if(y&t) {
flag=true;
}
}
}
}
if(flag) {
cout<<"INF\n";
} else cout<<ans<<"\n";
} else {
cout<<"INF\n";
}
}
signed main() {
//ios_untie();
#ifdef LOCAL
file_setup();
#endif
cin>>n>>k;
solve();
}
jell