#3057
Rabin-Miller
Se dă un număr natural n
. Să se afișeze DA
dacă numărul este prim altfel se afișează NU
.
Problema | Rabin-Miller | Operații I/O |
rabin-miller.in /rabin-miller.out
|
---|---|---|---|
Limita timp | 1 secunde | Limita memorie |
Total: 128 MB
/
Stivă 128 MB
|
Id soluție | #40404149 | Utilizator | |
Fișier | rabin-miller.cpp | Dimensiune | 1.39 KB |
Data încărcării | 07 Decembrie 2022, 21:39 | Scor / rezultat | Eroare de compilare |
rabin-miller.cpp:3:3: error: invalid preprocessing directive #It # It returns (x^y) % p ^ rabin-miller.cpp:10:22: error: stray '#' in program y = y >> 1; # y = y/2 ^ rabin-miller.cpp:16:7: error: invalid preprocessing directive #Pick # Pick a random number in [2..n-2] ^ rabin-miller.cpp:19:7: error: invalid preprocessing directive #Compute # Compute a^d % n ^ rabin-miller.cpp:25:7: error: invalid preprocessing directive #( # (i) d does not reach n-1 ^ rabin-miller.cpp:26:7: error: invalid preprocessing directive #( # (ii) (x^2) % n is not 1 ^ rabin-miller.cpp:27:7: error: invalid preprocessing directive #( # (iii) (x^2) % n is not n-1 ^ rabin-miller.cpp:40:7: error: invalid preprocessing directive #Corner # Corner cases ^ rabin-miller.cpp:46:11: error: invalid preprocessing directive #Find # Find r such that n = ^ rabin-miller.cpp:47:8: error: "^" is not a valid filename # 2^d * r + 1 for some r >= 1 ^ rabin-miller.cpp:52:11: error: invalid preprocessing directive #Iterate # Iterate given nber of 'k' times ^ rabin-miller.cpp:60:3: error: invalid preprocessing directive #Number # Number of iterations is 10 for better accuracy ^ rabin-miller.cpp:62:11: warning: character constant too long for its type [enabled by default] fh = open('primexxl.out', 'w') ^ rabin-miller.cpp:63:11: warning: character constant too long for its type [enabled by default] rh = open('primexxl.in', 'r') ^ rabin-miller.cpp:1:1: error: 'import' does not name a type import random ^ rabin-miller.cpp:6:5: error: 'x' does not name a type x = x % p; ^ rabin-miller.cpp:7:5: error: expected unqualified-id before 'while' while (y > 0): ^ rabin-miller.cpp:10:9: error: 'y' does not name a type y = y >> 1; # y = y/2 ^ rabin-miller.cpp:10:24: error: 'y' does not name a type y = y >> 1; # y = y/2 ^ rabin-miller.cpp:13:5: error: expected unqualified-id before 'return' return res; ^ rabin-miller.cpp:15:1: error: 'def' does not name a type def miillerTest(d, n): ^ rabin-miller.cpp:20:5: error: 'x' does not name a type x = power(a, d, n); ^ rabin-miller.cpp:22:5: error: expected unqualified-id before 'if' if (x == 1 or x == n - 1): ^ rabin-miller.cpp:28:5: error: expected unqualified-id before 'while' while (d != n - 1): ^ rabin-miller.cpp:30:9: error: 'd' does not name a type d *= 2; ^ rabin-miller.cpp:32:9: error: expected unqualified-id before 'if' if (x == 1): ^ rabin-miller.cpp:34:9: error: expected unqualified-id before 'if' if (x == n - 1): ^ rabin-miller.cpp:37:5: error: expected unqualified-id before 'return' return False; ^ rabin-miller.cpp:39:1: error: 'def' does not name a type def isPrime(n, k): ^ rabin-miller.cpp:43:5: error: expected unqualified-id before 'if' if (n <= 3): ^ rabin-miller.cpp:48:5: error: 'd' does not name a type d = n - 1; ^ rabin-miller.cpp:49:5: error: expected unqualified-id before 'while' while (d % 2 == 0): ^ rabin-miller.cpp:57:5: error: expected unqualified-id before 'return' return True; ^ rabin-miller.cpp:61:1: error: 'k' does not name a type k = 10; ^ rabin-miller.cpp:62:1: error: 'fh' does not name a type fh = open('primexxl.out', 'w') ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Rabin-Miller face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.