consider d=3 ==> n=8
consider the sequence 1 2 3 4 5 6 7 8
the answers for the players are
1:0
2:0
3:0
4: 24x24x2 (1=3C3)
5: 24x24x2x4 (4=4C3)
6: 24x24x2x10 (10=5C3)
7: 24x24x2x20 (20=6C3)
8: 24x24x2x35 (35=7C3)
which is nothing but (n/2)!x(n/2)!x2x((player_strength-1)C(n/2-1))(simple choosing which players can come in current player’s half and then permuting them)
you can precompute (n/2)!x(n/2)!x2
and further
4C3 can be written as 4x3x2/(3!)
5C3 can be written as 5x4x3/(3!)
6C3 can be written as 6x5x4/(3!)
7C3 can be written as 7x6x5/(3!)
you can observe that at ever step one multiplication and one division is there
eg. 5C3 = (4C3/2)*5, 6C3 = (5C3/3)*4
division can be done by modular multiplicative inverse
you find it here
http://discuss.codechef.com/questions/3433/modular-multiplicative-inverse
http://en.wikipedia.org/wiki/Modular_multiplicative_inverse
thus it can be solved in O(nlogn)