Skip to content

Commit 76864a4

Browse files
authored
Create ext_gcd.cpp
1 parent f4d49a2 commit 76864a4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Templates/ext_gcd.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
ll ext_gcd(ll a, ll b, ll& x, ll& y)
3+
{
4+
if (b == 0) {
5+
x = 1;
6+
y = 0;
7+
return a;
8+
}
9+
ll x1, y1;
10+
ll d = gcd(b, a % b, x1, y1);
11+
x = y1;
12+
y = x1 - y1 * (a / b);
13+
return d;
14+
}

0 commit comments

Comments
 (0)