Abiko‘s Motor

RRRRRRrrrrrrr 2023-11-18 12:03:39 2023-11-18 12:05:41

#include <bits/stdc++.h>
using namespace std;
#define int long long

//#define Var 12


int n;
bool vis[1000005];

int w_a_mozart(int x) {
	if (vis[x]) return 1e9+7;
	if (x == 1) return 0;
	if (x&1) return min(w_a_mozart(x+1),w_a_mozart(x-1))+1;
	else return w_a_mozart(x/2)+1;
}

signed main() {
	std::ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	cout << w_a_mozart(n);
	return 0;
}