#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long dp[10005] = { -1 }; int N; int f(int num) { int ret = 0; for (int i = 0; i < 32; i++) { if (num >> i & 1 == 1) ret++; } return ret; } int dfs(int num) { //numまで何歩でいけるかかえす。 if (num == 1) { //cout << "dp[" << num << "]: " << 1 << endl; return dp[1] = 1; } if (dp[num] != -1) { return dp[num]; } for (int i = 1; i <= N; i++) { //from i to num if (i + f(i) == num || i - f(i) == num) { //cout << "from i:" << i<<" to "<> N; for (int i = 1; i <= N; i++) dp[i] = -1; dfs(N); cout << dp[N] << endl; /* for (int i = 0; i < 64; i++) { cout <<"i:"<