#include #include #include using namespace std; int h[]={0,3,2,1,2,3,2,3,4,3,4,5,4,5,6,5,6,7,6,7,8}; int p[2000000]; int a[100]; int bound,i,j,n,m,s,t; bool flag; int count(int x){ x = (x & 0x55555555) + ((x >> 1) & 0x55555555); x = (x & 0x33333333) + ((x >> 2) & 0x33333333); x = (x & 0x0F0F0F0F) + ((x >> 4) & 0x0F0F0F0F); x = (x & 0x00FF00FF) + ((x >> 8) & 0x00FF00FF); x = (x & 0x0000FFFF) + ((x >> 16) & 0x0000FFFF); return x; } int f(int x){ return h[p[x]]; } void IDA(int d,int x,int tmp){ if(d==bound){ if(tmp==t){ flag=true; } return ; } if(f(tmp^t)+d>bound||(m-x)+d