#include #include #include using namespace std; int bitCount(int a){ a=(a&0x55555555)+(a>>1&0x55555555); a=(a&0x33333333)+(a>>2&0x33333333); a=(a&0x0f0f0f0f)+(a>>4&0x0f0f0f0f); a=(a&0x00ff00ff)+(a>>8&0x00ff00ff); a=(a&0x0000ffff)+(a>>16&0x0000ffff); return a; } int main(void){ int N; cin>>N; //bool flag[N]; vector m(N); //マスごとの移動数(絶対値) vector turn(N); //ターン数 vector flag(N); //訪れたことがあればtrue queue q; int me=0; turn[0]=1; q.push(me); for(int i=0;i=N)) {turn[me+canGoPlus]=turn[me]+1; q.push(me+canGoPlus);} if(!(me+canGoMinus<0)) {turn[me+canGoMinus]=turn[me]+1; q.push(me+canGoMinus);} flag[me]=true; } if(flag[N-1]==true) cout<