fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int P[100], S[100/32];
  5.  
  6. bool check(int n, int p)
  7. {
  8. return (bool) (n & (1<<p));
  9. }
  10.  
  11. int set(int n, int p)
  12. {
  13. return n = (n | (1<<p));
  14. }
  15.  
  16. void bitSieve(int n)
  17. {
  18. int i, j, lim = sqrt(n);
  19.  
  20. for(i=3; i<=lim; i+=2) {
  21. if(!check(S[i/32], i%32))
  22. for(j=i*i; j<=n; j+=i*2)
  23. S[j] = set(
  24. }
  25. }
  26.  
  27. int main()
  28. {
  29.  
  30. return 0;
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void bitSieve(int)':
prog.cpp:18: error: 'sqrt' was not declared in this scope
prog.cpp:24: error: expected primary-expression before '}' token
prog.cpp:24: error: expected `;' before '}' token
stdout
Standard output is empty