fork download
  1. #include<bits/stdc++.h>
  2. #define endl "\n"
  3. using namespace std;
  4. typedef long long ll;
  5. const int mod = 1e9 + 7;
  6.  
  7. int ucln(int a, int b){
  8. while(b != 0){
  9. int r = a%b;
  10. a = b;
  11. b = r;
  12. }
  13. return a;
  14. }
  15.  
  16. int bcnn(int a, int b){
  17. return a * b / ucln(a, b);
  18. }
  19.  
  20. int main(){
  21. int t;
  22. cin >> t;
  23. while(t--){
  24. int a, b;
  25. cin >> a >> b;
  26. cout << ucln(a, b) << " " << bcnn(a,b) << endl;
  27. }
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0.01s 5280KB
stdin
2
12 34
1234 5678
stdout
2 204
2 3503326