Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cb2068b

Browse filesBrowse files
committed
add extgcd
1 parent 24e4c4b commit cb2068b
Copy full SHA for cb2068b

File tree

2 files changed

+9
-0
lines changed
Filter options

2 files changed

+9
-0
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ AtCoder解説放送ライブラリ集
2424
|名前|コード|説明|
2525
|:--|:--|:--|
2626
|GCD/LCM|[gcd.cpp](gcd.cpp)|最大公約数と最小公倍数|
27+
|extgcd|[extgcd.cpp](extgcd.cpp)|Ai+Bj=gcd(A,B)なるi,jを求める|
2728
|Combination|[comb.cpp](comb.cpp)|nCkをmod素数で求める|
2829
|Matrix|[mat.cpp](mat.cpp)|行列|
2930
|素数|[prime.cpp](prime.cpp)|素数列挙と素因数分解|

‎extgcd.cpp

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// ai+bj=g
2+
// https://youtu.be/fDJpXN2R75A?t=6895
3+
ll extgcd(ll a, ll b, ll& i, ll& j) {
4+
if (b == 0) { i = 1; j = 0; return a;}
5+
ll p = a/b, g = extgcd(b,a-b*p,j,i);
6+
j -= p*i;
7+
return g;
8+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.