forked from pankaj443/CODEFORCES
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path520B.cpp
More file actions
47 lines (44 loc) · 738 Bytes
/
520B.cpp
File metadata and controls
47 lines (44 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1<<20;
vector<int>v;
int cnt,arr[N],b[N],has[N];
bool flag;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n,m;
cin>>n>>m;
if(n>=m)
{
cout<<n-m;
}
else
{
while(n!=m)
{
if(n>m)
{
cnt+=(n-m);
break;
}
else
{
if(m%2==1)
{
m++;
cnt++;
}
else
{
m/=2;
cnt++;
}
}
}
cout<<cnt;
}
return 0;
}
//_4_4_3_//