#include<bits/stdc++.h> #define N 10007 usingnamespacestd; typedeflonglong ll;
inline ll rd(){ ll x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == '-'); for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); return f ? -x : x; }
int a[67], b[67], c[67], m, n, len;
boolcheck(int pos){ for(int i = 1; i < pos; ++i) if(b[i] == 0) return0; for(int i = pos + len; i <= m; ++i) if(b[i] == 0) return0; for(int i = 1; i <= len; ++i) if(b[pos + i - 1] != c[i]) return0; return1; }
intmain(){ ll x = rd(), y = rd(); if(x == y) {puts("YES"); return0;} while(x != 0){ a[++n] = x % 2; c[n] = a[n]; x /= 2; } while(y != 0){ b[++m] = y % 2; y /= 2; } reverse(a + 1, a + 1 + n); reverse(b + 1, b + 1 + m); reverse(c + 1, c + 1 + n); len = n; while(c[len] == 0) len--; for(int i = 1; i <= m - len + 1; ++i){ if(check(i)) {puts("YES"); return0;} } reverse(c + 1, c + 1 + len); for(int i = 1; i <= m - len + 1; ++i){ if(check(i)) {puts("YES"); return0;} } a[++n] = 1; for(int i = 1; i <= n; ++i) c[i] = a[i]; len = n; for(int i = 1; i <= m - len + 1; ++i){ if(check(i)) {puts("YES"); return0;} } reverse(c + 1, c + 1 + len); for(int i = 1; i <= m - len + 1; ++i){ if(check(i)) {puts("YES"); return0;} } puts("NO"); return0; }
Post title:CF Round 760
Post author:Eva.Q
Create time:2021-12-15 18:56:50
Post link:https://qyy/2021/12/15/CF/CF-Round760-Div3/
Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.