fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4. int n, a, b;
  5. cin >> n;
  6. int t[n];
  7. for (int i=0; i<n; i++){
  8. cin >> a >> b;
  9. if (a==b)
  10. t[i]=a+b;
  11. else{
  12. while (a!=b){
  13. if (a<b)
  14. b-=a;
  15. else
  16. a-=b;
  17. }
  18. t[i]=a+b;
  19. }
  20.  
  21. }
  22. for (int i=0; i<n; i++)
  23. cout << t[i] << endl;
  24. return 0;
  25. }
Success #stdin #stdout 0s 3460KB
stdin
3
1 1
123 12345
9 6
stdout
2
6
6