Here is the problem: Problem
At first I thought that it was related to permutations, but I am not sure how are they generating the permutations for n=5.
Is there any math formula or is it purely programming based?
PS: This contest is not live currently and has ended a long time ago.