参考代码:
import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigInteger a = cin.nextBigInteger(); BigInteger b = cin.nextBigInteger(); System.out.print(gcd(a, b).toString()); } public static BigInteger gcd(BigInteger a, BigInteger b) { int val = b.compareTo(new BigInteger("0")); return val != 0 ? gcd(b, a.remainder(b)) : a; } }
0.0分
0 人评分