DiscreteLog_test.cpp 429 B

123456789101112131415161718192021
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef vector<int> VI;
  4. typedef pair<int, int> PII;
  5. #include "Euclid.cpp"
  6. #include "DiscreteLog.cpp"
  7. int main() {
  8. srand(time(NULL));
  9. assert(log_mod(407, 2891, 1459) == 276);
  10. for(int t = 0; t < 100; t++) {
  11. int a = rand()%5000;
  12. int b = rand()%5000;
  13. int n = rand()%5000;
  14. b %= n;
  15. int r = log_mod(a, b, n);
  16. assert(r == -1 || pow_mod(a, r, n) == b);
  17. }
  18. }