1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int x,r,n,m,y; 6 cin >>n>>m; 7 if(n<m) 8 {y=n,n=m,m=y;} 9 x=n*m; 10 while(m!=0) 11 {r=n%m; n=m; m=r;} 12 cout<<n<<" "<<x/n<<endl; 13 return 0; 14 }
时间: 2024-10-14 09:36:55
1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int x,r,n,m,y; 6 cin >>n>>m; 7 if(n<m) 8 {y=n,n=m,m=y;} 9 x=n*m; 10 while(m!=0) 11 {r=n%m; n=m; m=r;} 12 cout<<n<<" "<<x/n<<endl; 13 return 0; 14 }