fork(3) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int t, a, b;
  5. int main()
  6. {
  7. cin >> t;
  8. for (int i=0; i<t; i++)
  9. {
  10. cin >> a >> b;
  11. while (a>b)
  12. {
  13. a = a-b;
  14. }
  15. while (b>a)
  16. {
  17. b = b-a;
  18. }
  19. cout <<a+b;
  20.  
  21. }
  22. }
Success #stdin #stdout 0s 3464KB
stdin
5
1 1
2 4
9 6
6 9
1122 867
stdout
2469357