fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int L,R;
  6. cin>>L>>R;
  7. long long ans=0;
  8. long long x=1;
  9.  
  10. while(x<=R){
  11. if(x>=L){
  12. ans=ans+x;
  13. }
  14.  
  15. if(x>R/2){
  16. break;
  17. }
  18. x=2*x;
  19.  
  20. }
  21.  
  22.  
  23. cout<<ans<<endl;
  24. return 0;
  25. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
32767