This one is a lot more simple than 8 queens. The algorithm is - for each tile in your grid, if a black queen stood there, count how many placements of a white queen would threaten it. Then add it all up. What you really need to do is, given a tile, find the lengths of the column, row and diagonals that go through it (excluding the tile itself).
yeah, i know it must be simpler ..
although i din get ur algo, for itx not NxN board it can be any width n lenth as u see in sample,for example 100 x 223=10907100 ?
Consider a 5 x 6 grid with a black queen on a tile (1, 1)
* * * X
* Q * * * *
* * * X
* * X
X * X *
(X are just black tiles - I hoped they would improve readability). If a white queen was placed on any of *s, they would be able to capture each other. Thus you need to count all *s. Obviously the *s are placed on the same row, column and diagonals as Q. It's quite trivial to count..