/* -*- coding: utf-8 -*- * * 2954.cc: No.2954 Calculation of Exponentiation - yukicoder */ #include #include #include #include using namespace std; /* typedef */ using pii = pair; /* subroutines */ template T gcd(T m, T n) { // m >= 0, n >= 0 if (m < n) swap(m, n); while (n > 0) { T r = m % n; m = n; n = r; } return m; } pii readrat() { int p, q; scanf("%d.%d", &p, &q); int n = abs(p) * 10000 + q, d = 10000; if (p < 0) n = -n; int g = gcd(abs(n), d); n /= g, d /= g; return {n, d}; } /* main */ int main() { auto [an, ad] = readrat(); auto [bn, bd] = readrat(); if (bn < 0) { swap(an, ad); bn = -bn; } //printf(" a=%d/%d, b=%d/%d\n", an, ad, bn, bd); if (ad == 1) { if (bd == 1) { puts("Yes"); return 0; } int x0 = 1, x1 = an + 1; while (x0 + 1 < x1) { int x = (x0 + x1) / 2; if (pow(x, bd) > an) x1 = x; else x0 = x; } if (pow(x0, bd) == an) { puts("Yes"); return 0; } } puts("No"); return 0; }