模板-gcd
Posted titordong
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了模板-gcd相关的知识,希望对你有一定的参考价值。
GCD
int gcd(int a, int b)
{
return b == 0 ? a : gcd(b, a%b);
}
EXGCD
void ex_gcd(int a, int b, int &x, int &y)
{
if (b == 0)
{
x = 1;
y = 0;
return;
}
else
{
ex_gcd(b, a%b, x, y);
int t = x;
x = y;
y = t - (a / b)*y;
}
}
以上是关于模板-gcd的主要内容,如果未能解决你的问题,请参考以下文章