fork download
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5.  
  6. int NWW (int a, int b)
  7. {
  8. int g=0,q=0;
  9. g=a*b;
  10. while (b != 0)
  11. {
  12. q = a % b;
  13. a = b;
  14. b = q;
  15. }
  16. return g/a;
  17. }
  18. int main()
  19. {
  20. int size=0,a=0,b=0,c=0,d=0,temp1=0,temp2=0,temp3=0;
  21. cin>>size;
  22. while(size>0){
  23. cin>>a>>b>>c>>d;
  24. temp1=NWW(a,b);
  25. temp2=NWW(c,d);
  26. temp3=NWW(temp1,temp2);
  27. cout<<temp3<<endl;
  28. --size;
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 4200KB
stdin
2
2 3 4 5
30 15 10 25
stdout
60
150