#include #include // 2018. Giovanni Resta // Computes A(171760) for N = 1..11 and shows a possible // configuration. Running time for each case under one minute // on a modern PC. // To be compiled with gcc or another compiler // capable of 128-bit integers. Tested only under linux. // a board NxN with N<=11 is stored in 128-bit integer // using a bit for each square. // two queen configurations are then compatible if and only if // the binary AND of the corresponding integers is zero. // size of the board #define N (9) // QLong is how I call the 128-bit type typedef __uint128_t QLong; #if N>11 || N<1 #error Error: N out of range (1..11) #endif // number of possible configurations for N queens, N <= 11 const int nConf[12]={0, 1, 0, 0, 2, 10, 4, 40, 92, 352, 724, 2680}; // for printing boards const char S[12]={'.','1','2','3','4','5','6','7','8','9','A','B'}; // array of configurations QLong *C; // best result so far int best = 0; #define One ((QLong)1) // stores the configurations in the current solution QLong Qs[N]; // generates all the configurations of N queens and stores // them in array C. void GenConf() { int a[N]; int nC=0; void OutConf() { QLong t=0; for (int i=0; ibest) {best=q; PrQs(); if (q==N) return 1;} for (int i=p; i