Counting Permutations

HDU - 6310