#include using namespace std; #define REP(i,N) for(i=0;i P; typedef struct{ int first; int second; int third; }T; //昇順 bool comp_Se(T& l, T& r){ return l.second < r.second; } #define INF 1e9 int N; map memo; int numofbits(int bits){ bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff); } int dfs(int cur, set s){ if(cur<1 || cur>N) return INF; if(cur==N) return memo[cur]=1; if(memo.count(cur)) return memo[cur]; if(s.find(cur) != s.end()) return INF; s.insert(cur); int move = numofbits(cur); return memo[cur] = min(dfs(cur+move,s),dfs(cur-move,s))+1; } int main(void){ cin >> N; set s; int ans = dfs(1,s); if(ans