Reprint please specify the source [ametake All rights reserved]http://blog.csdn.net/ametake Welcome to see
It took me one hours to finally get the multiplication inverse in mind. In view of my clumsy IQ, hold on to these records. In this column Ming Cheriot girl and enthusiastic netizen HIMDD help and support
Then the text begins ...
What does inverse yuan do?
Because (A/b) mod p≠ (a mod p)/(b mod p)
We need to think of a way to avoid high-precision
That is to convert division into multiplication because (a*b) mod p = (a mod p) * (b mod p)
How to transform it? The inverse element appeared.
If x is present for the number a,c, so that a * X = 1 (mod C), then the x is the multiplicative inverse of a to C.
Plainly, dividing by a number modulo, the inverse modulo effect is the same as multiplying the number.
Why is the effect the same? Let's take a look at the following example:
12/4 MoD 7 =?, apparently the result is 3.
we are now on the pair (4,7), we can know X = 2 is 4 to 7 multiplication inverse is 2*4=1 (mod 7)
then we have (12/4) * (4 * 2) = (?) * (1) (mod 7)
Division is transformed perfectly to multiply
Theoretical basis:
f/a mod C =?
if present a*x = 1 (mod C)//Why is 1, because the above multiplication (?) * (1) (mod 7) should be 1 This number will not change
so the 2 sides multiply at the same time, get F * X =? (mod C)
Now we know that dividing by a number modulo equals multiplying the number of the inverse of the modulo is the next step is to find the inverse of the inverse element is actually to seek to make a*x = 1 (mod C) established X, where a is the divisor in the Division
Euler's theorem-Fermat theorem tells us: if A and P coprime , then A^phi (p) =1 (mod p); Specifically, when P is prime, a^ (p-1) =1 (mod p) because this time Phi (p) =p-1
Because A^phi (p) =1 (mod p) (meaning A^phi (p) mod p =1)
So a*a^ (Phi (p)-1) =1 (mod p) so that the contrast we can see is X is (PHI (p)-1)
We use X to represent the inverse of a, so it's a Phi (p)-1-Time Square.
And we can prove that: when a and f mutual element, a about modulo f multiplication inverse has the unique solution. If there is no reciprocity, then there is no solution. If f is prime, then any number from 1 to F-1 is the same as the F-element, i.e. between 1 and f-1 there is a multiplicative inverse of modulo f.
(Coprime the only solution is not coprime, although I do not understand why, Wang Josong Senior courseware also did not speak clearly, later ask it again (in fact, can consult often genius ... ))
In fact, the inverse element belongs to the category of group theory, but my humble knowledge of group theory is 0, so points degree is affected by
So how do we find the division to take the model? B/A mod C 1. Sieve method Euler function table O (NLOGN) 2. To find out the inverse of each function O (LOGN) * Enumeration requirements O (n) =o (NLOGN) Total O (2nlogn) =o (NLOGN)
This is using the Fermat theorem, and of course it can be extended to Euclid, but I don't quite understand it.
Warmly welcome the good man Ty June back to the XB group's Nest Hum (ˉ(∞)ˉ)
--The Jiangshan generation has the talent lady out, each leads the coquettish several hundred years
"Everyday Learning" multiplication inverse && Euler theorem && fermat theorem && Euler function application && University Bully