fork(6) download
  1. const int ML = 1e8 + 10;
  2. int cnt[ML], Pcnt[ML]; // cnt[n] = 0 iff n is prime; Pcnt[n] = amount of primes <= n
  3.  
  4. void prec() {
  5. for (int i = 2; i*i < ML; ++i) {
  6. if (cnt[i] == 0) {
  7. for (int j = i*i; j < ML; j += i) {
  8. cnt[j] = 1;
  9. }
  10. }
  11. }
  12. Pcnt[2] = 0;
  13. for (int i = 3; i < ML; ++i) {
  14. Pcnt[i] = Pcnt[i - 1] + (int)(cnt[i] == 0);
  15. }
  16. }
  17.  
  18. int bin_pow(int a, int p, int MOD) {
  19. int res = 1;
  20. while (p) {
  21. if (p & 1) {
  22. res = (res * 1ll * a) % MOD;
  23. }
  24. a = (a * 1ll * a) % MOD;
  25. p >>= 1;
  26. }
  27. return res;
  28. }
  29.  
  30. void solve(int test) {
  31. int n, m;
  32. scan(n, m);
  33. if (n <= 2) {
  34. print(0);
  35. }
  36. else {
  37. int ans = 1;
  38. for (int i = 3; i*i <= n; ++i) {
  39. if (cnt[i] == 0) {
  40. ll c = 0;
  41. int nn = n;
  42. while (nn > 1) {
  43. c += nn / i;
  44. nn /= i;
  45. }
  46. ans = (ans * 1ll * (c + 1)) % m;
  47. }
  48. }
  49. int rootN = sqrt(n);
  50. for (int i = 2; i <= rootN + 10000; ++i) {
  51. if (n / i < rootN) break;
  52. int cur = Pcnt[n / (i - 1)] - Pcnt[n / i];
  53. ans = (ans * 1ll * bin_pow(i, cur, m)) % m;
  54. }
  55. print((ans - 1ll + m) % m);
  56. }
  57. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
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
Standard output is empty