Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <cstring>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- int main(){
- cin.sync_with_stdio(false);
- cout.sync_with_stdio(false);
- ll n, d;
- ll res=0;
- ll maxdeg=1;
- cin >> n >> d;
- while(true){
- maxdeg<<=1;
- if (maxdeg>d)
- break;
- }
- ll deg=1;
- ll maxdegg=maxdeg;
- maxdeg-=2;
- while(true){
- //cout << maxdeg-deg+1 << endl;
- if((maxdeg-deg+1)<=d && (maxdeg-deg+1)>=n)
- res++;
- if ((maxdeg-deg+1)<n)
- break;
- deg<<=1;
- if (maxdeg-deg+1<=(maxdegg>>1)){
- maxdeg=((maxdeg+2)>>1)-2;
- maxdegg=maxdegg>>1;
- deg=1;
- }
- }
- cout << res;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement