First there are two restrictions:
1. At least four points.
2. From one point to another point, if they are connected through another point, if this point has not passed, then must pass, otherwise you can skip the middle point.
If you are unfamiliar with the restrictions, you can try it yourself.
The number of States is rarely only 2^9, so directly with the pressure DP get up ~ ~
Dp[i][state] represents the number of scenarios in which the state is last stopped on node I, where state is a binary number, 1 indicates that the point of the position has passed, and 0 indicates that it has not passed, then the equation for the transition is:
Dp[j][state| ( 1<<J)]+=dp[i][state] indicates state from I to j~~~.
The enumeration of the process of attention to various restrictions on the good ~ ~ ~
Directly on the code:
intcheck[9][9];intdp[Ten][ -];intMain () {memset (check,0,sizeof(check)); Memset (DP,0,sizeof(DP)); check[0][8]=check[8][0]=4; check[0][2]=check[2][0]=1; check[3][5]=check[5][3]=4; check[6][8]=check[8][6]=7; check[2][6]=check[6][2]=4; check[0][6]=check[6][0]=3; check[1][7]=check[7][1]=4; check[2][8]=check[8][2]=5; for(intI=0;i<9; ++i) dp[i][(1<<i)]=1; for(intI=1;i< (1<<9);++i) for(intj=0;j<9;++j)if(i& (1<<j)) for(intk=0;k<9;++k)if(! (i& (1<<k )))if(!check[j][k]| | (i& (1<<Check[j][k]))) Dp[k][i| (1<<K)]+=Dp[j][i]; intans=0; for(intI=0;i<9;++i) for(intj=1;j< (1<<9);++j) {intK=j,cnt=0; while(k) {++CNT; K=k& (K-1); } if(cnt>3) ans+=Dp[i][j]; } printf ("%d\n", ans); return 0;}
Using a pressure DP to calculate the number of unlocking schemes for nine Gongge on a mobile phone