Advertisement
Alexandre_lsv

Untitled

Mar 17th, 2016
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.     #include <cstring>
  3.     using namespace std;
  4.     typedef long long ll;
  5.     typedef long double ld;
  6.     int main(){
  7.         cin.sync_with_stdio(false);
  8.         cout.sync_with_stdio(false);
  9.         ll n, d;
  10.         ll res=0;
  11.         ll maxdeg=1;
  12.         cin >> n >> d;
  13.         while(true){
  14.             maxdeg<<=1;
  15.             if (maxdeg>d)
  16.                 break;
  17.         }
  18.         ll deg=1;
  19.         ll maxdegg=maxdeg;
  20.         maxdeg-=2;
  21.         while(true){
  22.             //cout << maxdeg-deg+1 << endl;
  23.             if((maxdeg-deg+1)<=d && (maxdeg-deg+1)>=n)
  24.                 res++;
  25.             if ((maxdeg-deg+1)<n)
  26.                 break;
  27.             deg<<=1;
  28.             if (maxdeg-deg+1<=(maxdegg>>1)){
  29.                 maxdeg=((maxdeg+2)>>1)-2;
  30.                 maxdegg=maxdegg>>1;
  31.                 deg=1;
  32.             }
  33.         }
  34.         cout << res;
  35.         return 0;
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement