fork download
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <cstdlib>
  4. using namespace std;
  5. int nwd(int a, int b)
  6. {
  7. while (a != b)
  8. {
  9. if (a < b)
  10. b -= a;
  11. else
  12. a -= b;
  13. }
  14. return a;
  15. }
  16. int NWW(int a,int b, int NWD)
  17. {
  18. return (a*b)/NWD;
  19. }
  20. int a,b,ile_testow;
  21. int main()
  22. {
  23. cin>>ile_testow;
  24. for(int i=0;i<ile_testow;i++)
  25. {
  26. cin>>a>>b;
  27. if ((a==0)||(b==0))
  28. {
  29. cerr<<"nie dodawaj 0";
  30. exit(1);
  31. }
  32. int NWD = nwd(a,b);
  33. cout<<NWW(a,b,NWD)<<endl;
  34. getchar();
  35. }
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0s 4436KB
stdin
2
12 15
11 22
stdout
60
22