Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <iostream>
- using namespace std;
- long long ind, all;
- long long a, b, i, szam, p = 1, x=1;
- bool prim(long long x)
- {
- bool ok = true;
- long long i;
- if(x == 0 or x == 1) return false;
- for(i = 2; i * i <= x; i ++)
- if(x % i == 0)
- {
- ok = false;
- break;
- }
- return ok;
- }
- int main()
- {
- cin >> a >> b;
- ind = log2(a) + 1;
- all = log2(b);
- for(i = 1; i <= ind; i ++)
- p = p * 2;
- if(prim(ind))
- {
- szam = szam + p - a;
- }
- for(i = ind; i < all; i ++)
- if(prim(i + 1))
- {
- szam = szam + p;
- p = p * 2;
- }
- else p = p * 2;
- if(prim(all + 1)) szam = szam + b - p+1;
- cout << szam << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement