DiscreteLog_test.cpp 419 B

1234567891011121314151617181920
  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. int r = log_mod(a, b, n);
  15. assert(r == -1 || pow_mod(a, r, n) == b%n);
  16. }
  17. }