/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%O:,*..***%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%O. .:&Oo.,&%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%O. .l%%%o..l*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%O*****************************************%%%%%&*olo*&%%< .:***; ,****&*%*&*************************************%% %&<****************. ..*****. .****. .**%%%%*..,:. .**o**. .**. ..**;&%&;*****. .*.**. .******. ..**. .**%% %%%*%%%%%%%%%%%%%%%O* ;&%%%%%&o. <&%%%*. l*%%%%&; ,0%*. :%%**l .*%%O* ;&%%%%%%%%%%%*< .&%%%%*. <*%%%%%O* ;&%%0; *O%%%% %%%%%%%%%%%%%%%%%%%0* :%%%%%%%*: .O%%%*. o%%%%%%*. *;. .*%%%%o .*%%0* :%%%%%%%%%%%%%l .O%%%%&. l%%%%%%0* ;*%%*: ,&%%%% %%%%%%%%%&<<<<<<<<<;. :%%%%%%&*. :*%%%*. o%%%%%&o. .*,. .,l**; .*%%0* :%%%%%%%%%%%%%l .O%%%%&. l%%%%%%0* ;*%%*: ,0%%%% %%%*&%%%%*<<,. .;<<;. :*%&,**..*l&%%%%*. o%%%*:. .lO%%&*l. .*%%0* :%%%%%%%0:,o&O* ,&%%%%&. l%%%&o<,. .;::;. ,&%%%% %%*<.l*%%%%%%*..*%%0* :%%0; ;&*%%%%%%l o%%&:.;**%%%%**:. ,<* .*%%0* :%%%%%%%&<. ...;&%%%%%&. l%%< .:;. . #pragma GCC optimize "trapv" using namespace std; typedef long long int lld; typedef unsigned long long int llu; #define TESTCASES() cin >> (T3X0); T353 = T3X0; while(T3X0--) #define input(V3C) for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7) #define mems(A77AY, V4LU) memset((A77AY), (V4LU), sizeof((A77AY))) #define CH3K(I7, E4, S7) (((S7)>0) ? (I7)<(E4) : (I7)>(E4)) #define for4(I7,S4,E4,S7) for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7)) #define forn(I7, E4) for(lld I7=0ll; I7 < E4; (I7)+=1ll) #define EACH(I7, A7) for (auto& I7: A7) #define len(v) ((int)((v).size())) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define pb push_back #define debspace(x) cout << #x << " = "; println(x); #define debline(x) cout << #x << " = "; print(x); cout << " "; #define f1 first #define s2 second #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator _it(_ss); huehue(_it, args); cout << "\n";} void huehue(istream_iterator it) {} template void huehue(istream_iterator it, T a, Args... args) { cout << *it << " = " << a << ", "; huehue(++it, args...); } template T inf() { return numeric_limits::max(); } void read() { return; } void print() { return; } void println() { cout << "\n"; return; } template T read(T& x) { cin >> x; return x; } template void print(T a) { cout << a; } template void println(T a) { cout << a << "\n"; } template void read(vector &arr) { EACH(i, arr) cin >> (i); } template void print(vector arr) { EACH(i, arr) {cout << i << " ";} } template void println(vector arr) { EACH(i, arr) {cout << i << " ";} cout << "\n"; } template void read(vector> &arr) { EACH(i, arr) read(i); } template void print(vector> arr) { EACH(i, arr) println(i); } template void println(vector> arr) { EACH(i, arr) println(i); } template void read(vector &arr, Args &... args) { read(arr); read(args...);} template void read(vector> &arr, Args &... args) { read(arr); read(args...);} template void read(T &a, Args &... args) { cin >> (a); read(args...); } template void print(vector &arr, Args &... args) { print(arr); print(args...);} template void print(T a, Args... args) { cout << a << " "; print(args...); }; template void println(vector &arr, Args &... args) { print(arr); println(args...);} template void println(T a, Args... args) { cout << a << " "; println(args...); }; const lld d4i[4] = { -1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1}; const lld d8i[8] = { -1, -1, 0, 1, 1, 1, 0, -1}, d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1}; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// const lld MOD = 1e12; lld power(lld x, lld y) { lld res = 1; x = x % MOD; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % MOD; y = y >> 1; x = (x * x) % MOD; } return res; } void solveEachTest(lld _TestCase = 1) { // cout << "Case#" << _TestCase << ": "; lld n, z; read(n, z); lld total = power(z, n); // vector powers; // forn(i, lld(1e6) + 1ll) { // if (i == 0) continue; // lld temp = power(i, n); // if (temp > lld(1e6)) break; // powers.pb(temp); // } // // debspace(powers); // bool ok = false; // EACH(i, powers) { // if (i >= total) break; // ok |= binary_search(all(powers), total - i); // if (ok) error(i); // } lld maxn = lld(1e6); bool ok = false; forn(i, maxn) { lld temp1 = power(i, n); if (temp1 >= total) break; forn(j, maxn) { lld temp2 = power(j, n); if (temp2 >= total) break; if (temp2 + temp1 == total) ok = true; } } println((ok) ? "Yes" : "No"); // cout << "\n"; return; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed; lld T3X0 = 0, T353 = 1; // TESTCASES() solveEachTest(T353 - T3X0); return 0; } // Random Thought : null // Message : If you get the anime reference in this code, we're friends and we can talk about LIFE. ;