TopCoder SRM 666 Div1 Medium SumOverPermutations

Codeforcesに出そう。 http://community.topcoder.com/stat?c=problem_statement&pm=13764