当前位置:网站首页>Multiplicative inverse action
Multiplicative inverse action
2022-06-13 11:02:00 【I can screw the bottle cap when I am born again】
First, let's talk about the inverse element :
Inverse element
Number theory reciprocal , It is also called inverse element
The reciprocal in number theory has a special meaning
Do you think a The reciprocal of is still in number theory 1/a Do you
(・∀・) Hem ~ naive
Let's first introduce the concept of remainder
(a + b) % p = (a%p + b%p) %p ( Yes )
(a - b) % p = (a%p - b%p) %p ( Yes )
(a * b) % p = (a%p * b%p) %p ( Yes )
(a / b) % p = (a%p / b%p) %p ( wrong )
Why division is wrong
It's hard to prove right , To prove wrong, just give a counterexample
(100/50)%20 = 2 ≠ (100%20) / (50%20) %20 = 0
For some topics , We must find the remainder in the middle process , Otherwise, the number is too large , The computer can't save , So if there's division in this equation , Are we unable to calculate this formula ?
The answer, of course, is NO (>o<)
Then you need the inverse element
We know
If
a*x = 1
that x yes a Reciprocal ,x = 1/a
however a If not 1, that x It's a decimal
In number theory , In most cases, there is a surplus , So now the problem has changed
a*x = 1 (mod p)
that x It must be equal to 1/a Do you
not always
So at this point , We will take x as a Reciprocal , Just add a remainder condition , therefore x be called a About p Inverse element
such as 2 * 3 % 5 = 1, that 3 Namely 2 About 5 Inverse element , Or say 2 and 3 About 5 It's the opposite of each other
In summary
set up c yes b Inverse element , Then there are b*c≡1(mod m);
inference :(a/b)mod m = (a/b)1mod m = (a/b)bc mod
m=ac(mod m); namely a/b The modulus of is equal to a * (b Inverse element ) The mold ;
This corollary explains why the inverse element is introduced ;
Function of inverse element
A word is , Change division to multiplication ;
for example seek (A / B) %p ; stay B When the value of is very large ,B As divisor , It is very likely that the precision will explode ; The divisor cannot be too large ; So we can turn it into multiplication to solve ;
(a/b)mod m = (a/b)*1mod m = (a/b)bc mod
m=ac(mod m);
namely a/b The modulus of is equal to a * (b Inverse element ) The mold ;
So the steps of finding this formula according to this inference are clear ;
Find out B Inverse element ( Extended Euclid , Fermat lemma + Fast power ) Can find ;
Just quote formula inference and apply it ;
边栏推荐
- vivo大规模 Kubernetes 集群自动化运维实践
- Implementation of singleton mode
- Modification of string class object
- ADG standby mrp0 status wait_ FOR_ GAP
- DNS protocol analysis
- 基于Vue+Nest.js+MySQL的跨平台开源社区运营管理系统
- CommonAPI与AUTOSAR AP通讯管理的异同
- [dynamic planning] beginner level
- Record several interesting XSS vulnerability discoveries
- Alibaba's employees decreased by 4000 in the first quarter; Programmers wrote scripts to hang up vaccine numbers and were arrested for making a profit of 400000 yuan; Sohu encounters epic email fraud,
猜你喜欢

Go zero microservice Practice Series (III. API definition and table structure design)
Some experience in database table structure design

Chapter VII document management

Database learning notes (Chapter 15)

Experience of electric competition - program-controlled wind pendulum

ue5 小知识点 random point in Bounding Boxf From Stream

Actual combat analysis of malicious code lab05-01

The first laravel workflow engine released the official version of v1.0

How to optimize MySQL?

终于,月入 20000 !!
随机推荐
Introduction to binary tree
Wechat applet customer service automatic reply - PHP implementation
Understand an article: Spark operation mode
Web 3.0?高成本版的P2P而已
统计特殊子序列数目(0,1,2)DP
2021CCPC网络赛榜单
WinForm resolves frequent refresh of black screen
欧拉函数和线性筛求欧拉函数
Review of last week's hot spots (6.6-6.12)
ADG standby mrp0 status wait_ FOR_ GAP
5.5 clock screensaver
Deploy vscode on kubernetes cluster
2022年劳务员-通用基础(劳务员)上岗证题目及答案
Vivo large scale kubernetes cluster automation operation and maintenance practice
21世纪以来的历次“粮食危机”,发生了什么?
We spent a weekend migrating 3.7 million lines of code to typescript
Use of servers
Spark source code (I) how spark submit submits jars and configuration parameters to spark server
JGR-A | 南京大学黄安宁团队揭示高原湖泊山地影响极端降水的动力-热力机制
CommonAPI与AUTOSAR AP通讯管理的异同