#include #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; #define ll long #define rep(i, m, n) for (ll i = m; i < n; i++) #define rrep(i, m, n) for (ll i = m - 1; i >= n; i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(), N.end()), N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(), n.end()) #define HOUT(S) cout << setprecision(50) << S << endl #define pint pair #define tint tuple #define endl "\n" #define mod 1000000007LL #define MAX 100010LL #define chmax(a, b) a = (((a) < (b)) ? (b) : (a)) #define chmin(a, b) a = (((a) > (b)) ? (b) : (a)) template vector make_v(size_t a) { return vector(a); } template auto make_v(size_t a, Ts... ts) { return vector(ts...))>(a, make_v(ts...)); } template typename enable_if::value != 0>::type fill_v(U& u, const V... v) { u = U(v...); } template typename enable_if::value == 0>::type fill_v(U& u, const V... v) { for (auto& e : u) fill_v(e, v...); } ll gcd(ll a, ll b) { if(b > a) swap(a, b); if(b == 0) return a; else return gcd(b, a % b); } map prime_factor(ll n) { map res; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { res[i]++; n /= i; } } if (n != 1) res[n] = 1; return res; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); string A, B; cin >> A >> B; Rev(A); if(B == "0.0000") cout << "Yes" << endl; else if(A.substr(0, 5) != "0000." && B[0] != '-') cout << "No" << endl; else if(B[0] != '-'){ Rev(B); ll a = 0; rep(i, 5, A.size()) a += (A[i] - '0') * pow(10, i - 5); bool f = true; ll b = 0; rep(i, 0, 4) b += (B[i] - '0') * pow(10, i); rep(i, 5, B.size()) b += (B[i] - '0') * pow(10, i); ll g = gcd(b, 10000); ll m = 10000 / g; auto mp = prime_factor(a); for(auto v : mp) { if(v.second % m != 0) f = false; } if(f) cout << "Yes" << endl; else cout << "No" << endl; //cout << a << " " << b << " " << g << " " << m << endl; } else { if(A.size() != 6 || A[5] != '0') cout << "No" << endl; else { ll a = 0; rep(i, 0, 4) a += (A[i] - '0') * pow(10, i); bool f = true; if(10000 % a != 0) f = false; else { a = 10000 / a; Rev(B); ll b = 0; rep(i, 0, 4) b += (B[i] - '0') * pow(10, i); rep(i, 5, B.size() - 1) b += (B[i] - '0') * pow(10, i); ll g = gcd(b, 10000); ll m = 10000 / g; auto mp = prime_factor(a); for(auto v : mp) { if(v.second % m != 0) f = false; } } if(f) cout << "Yes" << endl; else cout << "No" << endl; } } }