#include #include #include #include using namespace std; void calc(int step, int go[], int min[], int from, int to){ if(step < min[from]){ min[from] = step; //前に進む if(from + go[from] <= to){ calc(step + 1, go, min, from + go[from], to); } //後ろに進む if(from - go[from] >= 0){ calc(step + 1, go, min, from - go[from], to); } } } int main(){ //始まりの数値は1 const int Max = 10000; int go[Max] = {0}; int min[Max]; int n; int least; cin >> n; //移動可能数算出 for(int i=0; i 0){ if(least % 2 == 1){ go[i] ++; } least /= 2; } } //min表初期化 for(int i=0; i