int pow ( int a , int b , int c ) {
int ans = 1 ;
while ( b ) {
if ( b& 1 ) ans = ( 1LL* ans * a ) % c;
a = ( 1LL* a* a ) % c;
b >>= 1 ;
}
return ans;
}
bool miller( ll p, int it = 10 ) {
if ( p < 2 ) return 0 ;
if ( p ! = 2 && ( p & 1 ) == 0 ) return 0 ;
int s = p - 1 ;
while ( ( s & 1 ) == 0 ) s >>= 1 ;
while ( it-- ) {
int a = rand ( ) % ( p - 1 ) + 1 , temp = s;
int mod = pow ( a, temp, p) ;
while ( temp ! = p - 1 && mod ! = 1 && mod ! = p - 1 ) {
mod = ( 1LL* mod* mod ) % p;
temp <<= 1 ;
}
if ( mod ! = p - 1 && ( temp & 1 ) == 0 ) return 0 ;
}
return 1 ;
}
aW50IHBvdyggaW50IGEgLCBpbnQgYiAsIGludCBjICl7CiAgICBpbnQgYW5zID0gMTsgICAgCiAgICB3aGlsZSggYiApewogICAgICAgIGlmKCBiJjEgKSBhbnMgPSAoIDFMTCphbnMgKiBhICklYzsKICAgICAgICBhID0gKCAxTEwqYSphICklYzsKICAgICAgICBiID4+PSAxOwogICAgfSAgIAogICAgcmV0dXJuIGFuczsKfQpib29sIG1pbGxlcihsbCBwLCBpbnQgaXQgPSAxMCl7CiAgICBpZihwIDwgMikgcmV0dXJuIDA7CiAgICBpZihwICE9IDIgJiYgKHAgJiAxKSA9PSAwKSByZXR1cm4gMDsKICAgIGludCBzID0gcCAtIDE7CiAgICB3aGlsZSggKHMgJiAxKSA9PSAwKSBzID4+PSAxOwogICAgd2hpbGUoIGl0LS0gKXsKICAgICAgICBpbnQgYSA9IHJhbmQoKSAlIChwIC0gMSkgKyAxLCB0ZW1wID0gczsKICAgICAgICBpbnQgbW9kID0gcG93KGEsIHRlbXAsIHApOwogICAgICAgIHdoaWxlKHRlbXAgIT0gcCAtIDEgJiYgbW9kICE9IDEgJiYgbW9kICE9IHAgLSAxKXsKICAgICAgICAgICAgbW9kID0gKCAxTEwqIG1vZCptb2QgKSVwOwogICAgICAgICAgICB0ZW1wIDw8PSAxOwogICAgICAgIH0KICAgICAgICBpZihtb2QgIT0gcCAtIDEgJiYgKHRlbXAgJiAxKSA9PSAwKSByZXR1cm4gMDsKICAgIH0KICAgIHJldHVybiAxOwp9
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