const int ML = 1e8 + 10 ;
int cnt[ ML] , Pcnt[ ML] ; // cnt[n] = 0 iff n is prime; Pcnt[n] = amount of primes <= n
void prec( ) {
for ( int i = 2 ; i* i < ML; ++ i) {
if ( cnt[ i] == 0 ) {
for ( int j = i* i; j < ML; j + = i) {
cnt[ j] = 1 ;
}
}
}
Pcnt[ 2 ] = 0 ;
for ( int i = 3 ; i < ML; ++ i) {
Pcnt[ i] = Pcnt[ i - 1 ] + ( int ) ( cnt[ i] == 0 ) ;
}
}
int bin_pow( int a, int p, int MOD) {
int res = 1 ;
while ( p) {
if ( p & 1 ) {
res = ( res * 1ll * a) % MOD;
}
a = ( a * 1ll * a) % MOD;
p >>= 1 ;
}
return res;
}
void solve( int test) {
int n, m;
scan( n, m) ;
if ( n <= 2 ) {
print( 0 ) ;
}
else {
int ans = 1 ;
for ( int i = 3 ; i* i <= n; ++ i) {
if ( cnt[ i] == 0 ) {
ll c = 0 ;
int nn = n;
while ( nn > 1 ) {
c + = nn / i;
nn / = i;
}
ans = ( ans * 1ll * ( c + 1 ) ) % m;
}
}
int rootN = sqrt ( n) ;
for ( int i = 2 ; i <= rootN + 10000 ; ++ i) {
if ( n / i < rootN) break ;
int cur = Pcnt[ n / ( i - 1 ) ] - Pcnt[ n / i] ;
ans = ( ans * 1ll * bin_pow( i, cur, m) ) % m;
}
print( ( ans - 1ll + m) % m) ;
}
}
Y29uc3QgaW50IE1MID0gMWU4ICsgMTA7CmludCBjbnRbTUxdLCBQY250W01MXTsgLy8gY250W25dID0gMCBpZmYgbiBpcyBwcmltZTsgUGNudFtuXSA9IGFtb3VudCBvZiBwcmltZXMgPD0gbiAKIAp2b2lkIHByZWMoKSB7Cglmb3IgKGludCBpID0gMjsgaSppIDwgTUw7ICsraSkgewoJCWlmIChjbnRbaV0gPT0gMCkgewoJCQlmb3IgKGludCBqID0gaSppOyBqIDwgTUw7IGogKz0gaSkgewoJCQkJY250W2pdID0gMTsKCQkJfQoJCX0KCX0KCVBjbnRbMl0gPSAwOwoJZm9yIChpbnQgaSA9IDM7IGkgPCBNTDsgKytpKSB7CgkJUGNudFtpXSA9IFBjbnRbaSAtIDFdICsgKGludCkoY250W2ldID09IDApOwoJfQp9CiAKaW50IGJpbl9wb3coaW50IGEsIGludCBwLCBpbnQgTU9EKSB7CglpbnQgcmVzID0gMTsKCXdoaWxlIChwKSB7CgkJaWYgKHAgJiAxKSB7CgkJCXJlcyA9IChyZXMgKiAxbGwgKiBhKSAlIE1PRDsKCQl9CgkJYSA9IChhICogMWxsICogYSkgJSBNT0Q7CgkJcCA+Pj0gMTsKCX0KCXJldHVybiByZXM7Cn0KIAp2b2lkIHNvbHZlKGludCB0ZXN0KSB7CglpbnQgbiwgbTsKCXNjYW4obiwgbSk7CglpZiAobiA8PSAyKSB7CgkJcHJpbnQoMCk7Cgl9CgllbHNlIHsKCQlpbnQgYW5zID0gMTsKCQlmb3IgKGludCBpID0gMzsgaSppIDw9IG47ICsraSkgewoJCQlpZiAoY250W2ldID09IDApIHsKCQkJCWxsIGMgPSAwOwoJCQkJaW50IG5uID0gbjsKCQkJCXdoaWxlIChubiA+IDEpIHsKCQkJCQljICs9IG5uIC8gaTsKCQkJCQlubiAvPSBpOwoJCQkJfQoJCQkJYW5zID0gKGFucyAqIDFsbCAqIChjICsgMSkpICUgbTsKCQkJfQoJCX0KCQlpbnQgcm9vdE4gPSBzcXJ0KG4pOwoJCWZvciAoaW50IGkgPSAyOyBpIDw9IHJvb3ROICsgMTAwMDA7ICsraSkgewoJCQlpZiAobiAvIGkgPCByb290TikgYnJlYWs7CgkJCWludCBjdXIgPSBQY250W24gLyAoaSAtIDEpXSAtIFBjbnRbbiAvIGldOwoJCQlhbnMgPSAoYW5zICogMWxsICogYmluX3BvdyhpLCBjdXIsIG0pKSAlIG07CgkJfQoJCXByaW50KChhbnMgLSAxbGwgKyBtKSAlIG0pOwoJfQp9
compilation info
prog.cpp: In function 'void solve(int)':
prog.cpp:32:11: error: 'scan' was not declared in this scope
scan(n, m);
^
prog.cpp:34:10: error: 'print' was not declared in this scope
print(0);
^
prog.cpp:40:5: error: 'll' was not declared in this scope
ll c = 0;
^
prog.cpp:43:6: error: 'c' was not declared in this scope
c += nn / i;
^
prog.cpp:46:25: error: 'c' was not declared in this scope
ans = (ans * 1ll * (c + 1)) % m;
^
prog.cpp:49:21: error: 'sqrt' was not declared in this scope
int rootN = sqrt(n);
^
prog.cpp:55:28: error: 'print' was not declared in this scope
print((ans - 1ll + m) % m);
^
stdout