fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define IO ios_base::sync_with_stdio(0), cin.tie(0),cout.tie(0)
  4. typedef long long ll;
  5. const int N = 1e5 + 4 , MOD = 1e9 + 7 ;
  6. int num , load , ans ;
  7. int solve(int x)
  8. {
  9. if(x <= load)
  10. {
  11. ans++ ;
  12. return 0 ;
  13. }
  14. if(x % 2 ==0)
  15. solve(x / 2) + solve(x / 2) ;
  16. else
  17. solve(x / 2) + solve((x + 1) / 2) ;
  18. return ans ;
  19.  
  20. }
  21. int main() {
  22. IO ;
  23. while (cin>>num>>load)
  24. {
  25. ans = 0 ;
  26. cout<<solve(num)<<'\n' ;
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5512KB
stdin
Standard input is empty
stdout
Standard output is empty