fork download
  1. int pow( int a , int b , int c ){
  2. int ans = 1;
  3. while( b ){
  4. if( b&1 ) ans = ( 1LL*ans * a )%c;
  5. a = ( 1LL*a*a )%c;
  6. b >>= 1;
  7. }
  8. return ans;
  9. }
  10. bool miller(ll p, int it = 10){
  11. if(p < 2) return 0;
  12. if(p != 2 && (p & 1) == 0) return 0;
  13. int s = p - 1;
  14. while( (s & 1) == 0) s >>= 1;
  15. while( it-- ){
  16. int a = rand() % (p - 1) + 1, temp = s;
  17. int mod = pow(a, temp, p);
  18. while(temp != p - 1 && mod != 1 && mod != p - 1){
  19. mod = ( 1LL* mod*mod )%p;
  20. temp <<= 1;
  21. }
  22. if(mod != p - 1 && (temp & 1) == 0) return 0;
  23. }
  24. return 1;
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:10:13: error: ‘ll’ was not declared in this scope
 bool miller(ll p, int it = 10){
             ^
prog.cpp:10:19: error: expected primary-expression before ‘int’
 bool miller(ll p, int it = 10){
                   ^
prog.cpp:10:30: error: expression list treated as compound expression in initializer [-fpermissive]
 bool miller(ll p, int it = 10){
                              ^
prog.cpp:10:31: error: expected ‘,’ or ‘;’ before ‘{’ token
 bool miller(ll p, int it = 10){
                               ^
stdout
Standard output is empty