- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef pair<int, int> pii;
- typedef pair<ll, ll> pll;
- #define debug(x) cerr << #x << " = " << (x) << endl;
- #define debug_pii(x) cerr << "(" << x.first << "," << x.second << ")";
- #define rep(i, n) for(int i = 0;i < n;i++)
- #define pb push_back
- #define F first
- #define S second
- // template<typename _Ty1, typename _Ty2>
- // ostream& operator<<(ostream& _os, const pair<_Ty1, _Ty2>& _p) {
- // _os << '(' <<_p.first << ',' << _p.second << ')';
- // return _os;
- // }
- //
- // template<typename _Ty1, typename _Ty2>
- // istream& operator>>(istream& _is, pair<_Ty1, _Ty2>& _p) {
- // _is >> _p.first >> _p.second;
- // return _is;
- // }
- string solve2(ll u, ll v) {
- if(v < u) return "NO";
- if(v == u) return "YES";
- ll x = u;
- ll diff = v-u;
- for(int i = 0;i < 30;i++) {
- bool z1 = x & (1LL << i);
- bool z2 = diff & (1LL << i);
- if(z1 == false && z2 == true) {
- bool possible = false;
- for(int j = i-1;j >= 0;j--) {
- bool u1 = x & (1LL << j);
- bool u2 = diff & (1LL << j);
- if(u1 == true && u2 == true) {
- possible = true;
- break;
- }
- if(u1 == false && u2 == false) {
- break;
- }
- }
- if(!possible) return "NO";
- }
- }
- return "YES";
- }
- string solve(ll u, ll v) {
- if(v < u) return "NO";
- ll x = 0, y = 0;
- for(int i = 0; i < 30; i++) {
- if (u & (1 << i)) x++;
- if (v & (1 << i)) y++;
- if (x < y) return "NO";
- }
- return "YES";
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- string s1, s2;
- for(int ii = 1; ii < 50; ii++) {
- for(int jj = 1; jj < 50; jj++) {
- s1 = solve(ii,jj);
- s2 = solve2(ii,jj);
- if (s1 != s2) cout << "Fail: u = " << ii << ", v = " << jj << ": " << "correct answer is " << s1 << ", your answer is " << s2 << endl;
- }
- }
- return 0;
- }