fork download
  1. #include <iostream>
  2. #include <math.h>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. int nwd(int a, int b)
  8. {
  9. if (b == 0)
  10. return a;
  11. else
  12. return nwd(b, a%b);
  13. }
  14.  
  15. int p;
  16.  
  17. main(){
  18.  
  19. cin >> p;
  20. int a;
  21. int b;
  22.  
  23. for (int i=0; i<p; i++)
  24. {
  25. cin >> a;
  26. cin >> b;
  27.  
  28. cout << nwd(a,b) << endl;
  29.  
  30. }
  31.  
  32.  
  33. return 0;
  34.  
  35. }
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
Standard output is empty