- C24zhengfujia's blog
gcd
- @ 2025-5-11 21:24:07
template <typename int_type>
int_type gcd(int_type x, int_type y) // 最大公约数
{
int_type r;
if (x < y)
{
r = x;
x = y;
y = r;
}
r = x % y;
while (r)
{
x = y;
y = r;
r = x % y;
}
return y;
}