#include
#include
using namespace std;
typedef long long ll;
ll n,m,x,y,s1,s2,ans;
ll gcd(ll m,ll n){
while(m>0){ll c=n%m;n=m;m=c;}
return n;
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);
cin>>n>>m>>x>>y;
ll tmp=gcd(x,y);
x/=tmp;y/=tmp;
ans=min(n/x,m/y);
cout<
我的代码比较长,下面有个短的。__gcd()函数的头文件是algorithm
#include
#include
using namespace std;
int main(){
long long a,b,x,y,g;
cin>>a>>b>>x>>y;
g=__gcd(x,y);cout<x/=g;y/=g;
cout<);
}