fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n;
  5. scanf("%d", &n);
  6. for (int i = 0; i < n; i++) {
  7. long long a, b, temp;
  8. scanf("%lld%lld", &a, &b);
  9. while (a != 0 && b != 0) {
  10. temp = b;
  11. b = a;
  12. a = temp % a;
  13. }
  14. if (a == 0)
  15. printf("%lld\n", b);
  16. else
  17. printf("%lld\n", a);
  18. }
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.01s 5288KB
stdin
3
12 18
7 11
10 10
stdout
6
1
10