int gcd(int a, int b) { while (a % b) { int t = a % b; a = b; b = t; } return b; }