Petr's problem P78605


Statement
 

pdf   zip

A permutation p1,,pnp_1, \dots, p_n is a sequence of numbers between 1 and nn such that each number appears exactly once. An inversion in a permutation is a pair of indices (i,j)(i, j) such that i<ji < j but pi>pjp_i > p_j. The weight of an inversion (i,j)(i, j) is jij - i.

How many permutations of nn elements exist where the sum of weights of all inversions is equal to xx? For instance, there are exactly two such permutations for n=4n = 4 and x=4x = 4: 3, 2, 1, 4 and 1, 4, 3, 2.

Input

Input consists of several cases, each one with nn and xx. You can assume 1n141 \le n \le 14 and 0x(n+1)n(n1)/60 \le x \le (n + 1)n(n - 1)/6.

Output

For every case, print the number of permutations of nn elements such that the sum of weights of all inversions is xx.

Public test cases
  • Input

    4 4
    1 0
    14 455
    14 200
    

    Output

    2
    1
    1
    486253544
    
  • Information
    Author
    Petr Mitrichev
    Language
    English
    Official solutions
    C++
    User solutions
    C++