#include #include #include #include #include #include #include #define rep(i,n) for(i=0; i> a #define out(a,b) cout << a << b using namespace std; using lint = long long; bool is_prime(lint n){ if(n==2||n==3) return true; if(n<2||n%2==0) return false; bool f=true; for(lint i=3; i*i<=n; i+=2){ if(n%i==0){ f=false; break; } } return f; } vector> prime_factorize(int n){ vector> prime_factors; lint p=2, cnt=0; while(n>1){ if(n%p!=0){ if(cnt!=0){ prime_factors.push_back(make_pair(p, cnt)); cnt=0; } do{p++;}while(!is_prime(p)); } else{ n/=p; cnt++; } } prime_factors.push_back(make_pair(p, cnt)); return prime_factors; } lint div_much(lint num, lint r){ lint cnt=0; while(num%r==0){ num/=r; cnt++; } return cnt; } int main(void){ // lint i, j; lint n, m; lint x, a, y, b; in(x); in(a); in(y); in(b); vector> primes_y=prime_factorize(y); lint y_i=primes_y.size(); bool covered=true; lint i, j=0; rep(i,y_i){ lint n_y, p_y, cnt; tie(p_y, n_y)=primes_y[i]; cnt=div_much(x ,p_y); if(cnt*a