Tara's Beautiful Permutations

  • + 1 comment

    what, the Editorial is so greatful.But I think this problem is a combinatorics problem. And use inclusion-exclusion principle let~s define var "all" be the number of the total number which occuer twice. let`s define var ans be the total number of permutation of all the number. it can calc it A(n, n) / (all * 2!) and now we use inclusion-exclusion principle. for (k := 1 to all) mean that there are k pair number break the problem condition so we should add the number when k is even and cut the number when k is odd