#include<iostream> using namespace std; int main(){ long a,b,r,n; cin>>a>>b; r=a%b;//a>b时取r n=a*b; while(r){//r!=0;即a<b时情况 a=b; b=r; r=a%b; } cout<<b+n/b<<endl; return 0; }
#include<iostream> using namespace std; int main(){ long a,b,r,n; cin>>a>>b; r=a%b;//a>b时取r n=a*b; while(r){//r!=0;即a<b时情况 a=b; b=r; r=a%b; } cout<<b+n/b<<endl; return 0; }