Balloon Fight

Problem is here:
Can Anyone tell me which previous problem is similar to this problem as well as how to derive formula for it?

The question is same as that of two queens problem(easiest sub problem of the n queen problem)ie placing 2 queens on a chess board such that they dont attack each other.

Here is the link for n queen’s problem :

So you can apply a similar approach in this question. Instead of that i used PNC and got the formula for this question as number_of_ways=i.j.(j+i-2)+2.i.(i-1).(3.j-i-1)/3 (. means product)

Here is the link to my code:

The approach of n queen will become very time consuming!could you give me the link to study the above formulae as i am not able to understand how it is derive?