ACM数论算法-(精品课件).pptVIP

  • 7
  • 0
  • 约2.68万字
  • 约 100页
  • 2018-10-14 发布于广西
  • 举报
Congruence equations(cont. 7) Theorem 6: If the common solution for (7) exists, it can be computed as (8) where Miller-Ribin method for quasi-primality testing Lemma 1: If p is a prime number, then Congruence equations(cont. 8) (9) iff. x??1 (mod p). Lemma 2: If the following quadratic congruence equation has solution not equal to ?1 , (10) then m is a composite number (not prime number). Theorem 6(Quasi-primality testing): Given any odd integer m, m can be represented as m=1+2jd, where 2j||(m-1). Randomly choose an integer within 1~m, the so-called b-sequence is defined by Congruence equations(cont. 9) (11) Due to lemma 2, if m is a prime, the b-sequence modulo m results in residue numbers as where ?s represent integers not equal to 1. Congruence equations(cont. 10) Key point: In the b-sequence modulo m result sequence, (a) the result before the first 1 cannot be ?; ( can be the before beginning or -1) (b) 1 has to occur in the result sequence. If b-sequence satisfies above (a) and (b), m is passed the primality testing based on b-sequence. Theorem 7: Randomly choose k integers b1,b2,···,bk within 1~m, the probability that m can get pass above quasi-primality testing based on every bi-sequence (i=1,2,···,k) is 1/4k. Congruence equations(cont. 11) k 1/4k 10 10-6 25 10-15 30 10-18 50 10-30 100 10-60 168 10-101 1000 10-602 ACM exercise 1: Given a large positive integer, present that it is a prime or not. Input: The first line is an integer T, representing T integers need to test. Beneath the first line, there are T lines providing T integers denoted by N (2N21024). Output: If N is prime, output prime in a line, otherwise output not prime. Algorithm description: 1) k=1000; // probability of composite number10-601 2) read N; 3) computing j and d; 4) generating a random number b within 1~N. 5) r0=-1; r=bd mod N; i=1; 6) if (r=1) or (i=j), then goto 9); otherwise do 7); 7) r0=r; r=(r?r) mod N; i++; 8

文档评论(0)

1亿VIP精品文档

相关文档