Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- //o functie pentru a verifica daca un nr este prim...
- bool prim(unsigned long long int n)
- {
- unsigned long long int d;
- if(n==2)
- return true;
- if(n<2 || n%2==0)
- return false;
- for(d=3; d*d<=n; d+=2)
- if(n%d==0)
- return false;
- return true;
- }
- // calculez nr de biti si verific daca nr de biti este prim
- bool nrDeBiti(unsigned long long int n)
- {
- unsigned long long int k=0;
- while(n)
- {
- ++k;
- n/=2;
- }
- if(prim(k))
- return true;
- return false;
- }
- //citesc intervalul [a,b]...
- int main()
- {
- unsigned long long int a,b,c=0,i;
- cin>>a>>b;
- for(i=a; i<=b; ++i)
- {
- if(nrDeBiti(i))
- ++c;
- }
- cout<<c;
- return 0;
- }
- #1479 pretios de pe pbinfo
- rezultat 40pct...?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement