Advertisement
Saleh127

Untitled

Apr 17th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. long long a,b,c=0,d,e,f,i,j,k,l;
  6. cin>>a>>b;
  7. if(a==b) cout<<0<<endl;
  8. else if(a>b) cout<<a-b<<endl;
  9. else
  10. {
  11. while(b-a!=0)
  12. {
  13. if(b%2!=0 || b<a) b++;
  14. else b/=2;
  15. c++;
  16. }
  17. cout<<c<<endl;
  18. }
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement