Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <math.h>
  2. #include <iostream>
  3. using namespace std;
  4. long long ind, all;
  5. long long a, b, i, szam, p = 1, x=1;
  6. bool prim(long long x)
  7. {
  8. bool ok = true;
  9. long long i;
  10. if(x == 0 or x == 1) return false;
  11. for(i = 2; i * i <= x; i ++)
  12. if(x % i == 0)
  13. {
  14. ok = false;
  15. break;
  16. }
  17. return ok;
  18. }
  19.  
  20. int main()
  21. {
  22. cin >> a >> b;
  23. ind = log2(a) + 1;
  24. all = log2(b);
  25. for(i = 1; i <= ind; i ++)
  26. p = p * 2;
  27. if(prim(ind))
  28. {
  29. szam = szam + p - a;
  30. }
  31. for(i = ind; i < all; i ++)
  32. if(prim(i + 1))
  33. {
  34. szam = szam + p;
  35. p = p * 2;
  36. }
  37. else p = p * 2;
  38. if(prim(all + 1)) szam = szam + b - p+1;
  39. cout << szam << " ";
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement