fork(3) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int a,b,testy;
  6.  
  7. int main()
  8. {
  9. cin>>testy;
  10.  
  11. for (int i=0; i<testy; i++)
  12. {
  13. cin>>a>>b;
  14.  
  15. while (a!=b)
  16. {
  17. if (a<b) b=b-a;
  18. else if (b<a) a=a-b;
  19. }
  20. cout<<a+b;
  21.  
  22. a=0; b=0;
  23. }
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 4264KB
stdin
Standard input is empty
stdout
Standard output is empty