Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n,m;
- cin>>n>>m;
- int p(0);
- if(n>m)
- {
- while(n!=m)
- {
- n=n-1;
- p++;
- }
- }
- else
- {
- while(!0)
- {
- p++;
- if(m%2==0)
- m/=2;
- else
- m++;
- if(m<=n)
- {
- if(m==n)
- break;
- else{
- p=p+n-m;
- break;
- }
- }
- }
- }
- cout<<p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement