Files
Story-With-Thanh/J03011 - ƯỚC SỐ CHUNG LỚN NHẤT CỦA SỐ NGUYÊN LỚN.java
T
2022-12-15 23:51:04 +07:00

19 lines
505 B
Java

import java.math.BigInteger;
import java.util.Scanner;
public class Main {
static BigInteger gcd(BigInteger a, BigInteger b){
if(b.equals(BigInteger.ZERO)) return a;
return gcd(b,a.mod(b));
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
BigInteger a=sc.nextBigInteger(), b=sc.nextBigInteger();
System.out.println(gcd(a,b));
}
sc.close();
}
}