#include #include #include #include using namespace std; #define MAX_N 10000 int N; queue que; vector dp(MAX_N + 1, -1); int binary_1_count(int num){ int count_1 = 0; while (num > 1){ if (num % 2 == 1) count_1 += 1; num /= 2; } count_1 += 1; return count_1; } int main(){ // cin.tie(0); cin>>N; que.push(1); dp[1] = 1; while (que.size() > 0) { int q = que.front(); int count_1 = binary_1_count(q); array list{-count_1, count_1}; for (auto e : list) { if ((q + e) > 0 && dp[q + e] == -1) { dp[q+e] = dp[q] + 1; que.push(q+e); } } que.pop(); } if (dp[N] != -1) cout<