#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(int r_sml, int n_lrg){ lint cnt=0; while(n_lrg%r_sml==0){ n_lrg/=r_sml; cnt++; } return cnt; } int main(void){ lint i, j; lint p, n, m; lint x, a, y, b; in(x); in(a); in(y); in(b); vector> y_prime=prime_factorize(y); bool f=true; rep(i,y_prime.size()){ tie(p, n)=y_prime[i]; m=div_much(p,x); if(m*a