【发布时间】:2021-04-15 14:09:34
【问题描述】:
a very nice way 可以在 python-3.8 中找到模逆(即,对于给定的 a 和 python-3.8,例如 b 和 ab ≡ 1 (mod m)):
b = pow(a, -1, m)
pow 内置在 python-3.8 中。 c++有这样的东西吗?
【问题讨论】:
-
并回答您的问题:不,afaik 在标准库中没有这样的功能(ofc 有
std::pow但它只需要 2 个参数,不做模数) -
@JohnD,谢谢,这些帖子对我有帮助,但它们并没有回答我的问题 - 我在我的问题中强调了 内置 的性质。
标签: python-3.8 python-3.8 c++ c++ python-3.x built-in integer-arithmetic modular-arithmetic