# Include "stdio. h"
# Define N 8 // because the calculated data is too large, it takes a long time to calculate it. You can change the value of N for testing.
# Include "iostream. h" // This algorithm adopts the Backtracking Method.
Enum bin {fal, tr}; // if there is a better algorithm, please send me an email. Thank you.
Int top = 0;
Long int num = 0;
Int row [] = {-1,-2,-2,-, 1 };
Int col [] = {-2,-, 1,-1,-2 };
Bin mark [N] [N];
Struct stack
{
Int x, y;
Int dir;} board [N * N];
Void push (stack it)
{
Board [top]. x = it. x;
Board [top]. y = it. y;
Board [top]. dir = it. dir;
Mark [board [top]. x] [board [top]. y] = tr;
Top ++;
}
Stack pop ()
{
-- Top;
Mark [board [top]. x] [board [top]. y] = fal;
Board [top]. dir ++;
Return board [top];
}
Bin empty ()
{
If (top = 0) return tr;
Else return fal;
}
Void main ()
{
Stack temp = {N-1, N-1,-1 };
Push (temp );
While (! Empty ())
{
Int g, h;
Temp = pop ();
Int I = temp. x;
Int j = temp. y;
Int dir = temp. dir;
While (dir <8)
{
G = I + row [dir];
H = j + col [dir];
If (g <0) | (h <0) | (g> = N) | (h> = N) | mark [g] [h]) dir ++;
Else {
If (g = 0 & h = 0) {num ++; dir ++ ;}
Else {
Temp. x = I;
Temp. y = j;
Temp. dir = dir;
Push (temp );
& N