fork download
  1. #include <iostream>
  2. #include "bits/stdc++.h"
  3. #define ll long long
  4.  
  5. using namespace std;
  6.  
  7. // Get divisors of n O(sqrt(n))
  8. vector<ll>d;
  9. void divisors(ll n)
  10. {
  11. for(ll i=1; i*i<=n; i++)
  12. {
  13. if(n%i==0)
  14. {
  15. d.push_back(i);
  16. if(i!=(n/i)) // Complement , ex: 2,2 false for n=4
  17. {
  18. d.push_back(n/i);
  19. }
  20. }
  21. }
  22. }
  23.  
  24. //Checks if number is prime O(sqrt(n))
  25. bool isPrime(ll a)
  26. {
  27. for(ll i=2; i*i<=a; i++)
  28. {
  29. if(a%i==0)
  30. {
  31. return false;
  32. }
  33. }
  34. return true;
  35. }
  36.  
  37. // Sieve algorithm O(n*log(log(n)))
  38. bool prime[N];
  39. void Sieve(ll n)
  40. {
  41. memset(prime,true,sizeof(prime));
  42. for(ll p=2; p*p<=n; p++)
  43. {
  44. if(prime[p])
  45. {
  46. for(ll i=p*p; i<=n; i+=p)
  47. {
  48. prime[i]=false;
  49. }
  50. }
  51. }
  52. }
  53.  
  54. // SPF algorithm O(n*log(log(n)))
  55. ll spf[N];
  56. void SPF()
  57. {
  58. for(int i=1; i<N; i++)
  59. {
  60. spf[i]=i;
  61. }
  62. for(int i=2; i*i<N; i++)
  63. {
  64. if(spf[i]==i)
  65. {
  66. for(int k=i*i; k<N; k+=i)
  67. {
  68. if(spf[k]==k)
  69. {
  70. spf[k]=i;
  71. }
  72. }
  73. }
  74. }
  75. }
  76.  
  77.  
  78. int main()
  79. {
  80.  
  81. }
  82.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:38:12: error: ‘N’ was not declared in this scope
 bool prime[N];
            ^
prog.cpp: In function ‘void Sieve(long long int)’:
prog.cpp:41:12: error: ‘prime’ was not declared in this scope
     memset(prime,true,sizeof(prime));
            ^~~~~
prog.cpp:41:12: note: suggested alternative: ‘stime’
     memset(prime,true,sizeof(prime));
            ^~~~~
            stime
prog.cpp: At global scope:
prog.cpp:55:8: error: ‘N’ was not declared in this scope
 ll spf[N];
        ^
prog.cpp: In function ‘void SPF()’:
prog.cpp:58:20: error: ‘N’ was not declared in this scope
     for(int i=1; i<N; i++)
                    ^
prog.cpp:60:9: error: ‘spf’ was not declared in this scope
         spf[i]=i;
         ^~~
prog.cpp:62:22: error: ‘N’ was not declared in this scope
     for(int i=2; i*i<N; i++)
                      ^
prog.cpp:64:12: error: ‘spf’ was not declared in this scope
         if(spf[i]==i)
            ^~~
stdout
Standard output is empty