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