fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define gc getchar_unlocked
  4. #define fo(i,n) for(i=0;i<n;i++)
  5. #define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
  6. #define ll long long
  7. #define si(x) scanf("%d",&x)
  8. #define sl(x) scanf("%lld",&x)
  9. #define ss(s) scanf("%s",s)
  10. #define pi(x) printf("%d\n",x)
  11. #define pl(x) printf("%lld\n",x)
  12. #define ps(s) printf("%s\n",s)
  13. #define pb push_back
  14. #define mp make_pair
  15. #define F first
  16. #define S second
  17. #define all(x) x.begin(), x.end()
  18. #define clr(x) memset(x, 0, sizeof(x))
  19. #define sortall(x) sort(all(x))
  20. #define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
  21. #define PI 3.1415926535897932384626
  22. typedef pair<int, int> pii;
  23. typedef pair<ll, ll> pl;
  24. typedef vector<int> vi;
  25. typedef vector<ll> vl;
  26. typedef vector<pii> vpii;
  27. typedef vector<pl> vpl;
  28. typedef vector<vi> vvi;
  29. typedef vector<vl> vvl;
  30. int mpow(int base, int exp);
  31. void ipgraph(int m);
  32. void dfs(int u, int par);
  33. const int mod = 1000000007;
  34. const int N = 3e5, M = N;
  35. //=======================
  36.  
  37. vi g[N];
  38. int a[N][30];
  39.  
  40. int main()
  41. {
  42. ios_base::sync_with_stdio(false);
  43. cin.tie(NULL);
  44. int i,n,k,j,l,r;
  45.  
  46. cin >> l >> r;
  47.  
  48. Fo(i, l, r+1) a[i][0] = i;
  49. Fo(i, 1, 30){
  50. //differ in 1st i bits
  51. Fo(j, 1, N){
  52. a[j][i] = a[j][i-1];
  53. if( (1<<(i-1) & j) != 0 ){
  54. //i th bit is set
  55. a[j][i] |= a[j^(1<<(i-1))][i-1];
  56. }
  57. }
  58. }
  59. int ans = 0;
  60. Fo(i, 1, N) ans += a[i][29] == i;
  61. cout << ans << endl;
  62. return 0;
  63. }
  64.  
  65.  
Success #stdin #stdout 0.12s 58240KB
stdin
65 98
stdout
63