Some algorithms samples on C++ and Python for both CTF.Crypto and ACM/OI. Btw,it also can use in other fileds.
一些用C++和Python实现的算法模板,可以用于CTF.Crypto和ACM/OI。顺便说一句,它也可以用于其他领域。
算法 | 函数名 | Python | C++ |
---|---|---|---|
欧几里得算法 | gcd | ✔ | ✔ |
扩展欧几里得算法 | exgcd | ✔ | ✔ |
逆元 | inverse | ✔ | ✔ |
求解线性同余方程 | linear_congruence | ✔ | ✔ |
快速幂 | pow | ⭕ | ✔ |
有理数x/y分解为连分数 | rational_to_contfrac | ✔ | ✔ |
无理数sqrt(n)分解为连分数 | irrational_sqrtn_to_contfrac | ✔ | ❌ |
连分数还原有理数x/y | contfrac_to_rational | ✔ | ✔ |
连分数计算渐进分数 | convergents_from_contfrac | ✔ | ✔ |
ASCII转UNICODE | ascii_to_unicode | ✔ | ❌ |