Score : 900 points
Problem Statement
How many different sequences of length 2N, A=(A1,A2,…,A2N), satisfy both of the following conditions?
- The sequence A contains N occurrences of +1 and N occurrences of −1.
- There are exactly K pairs of l and r (1≤l≤r≤2N) such that Al+Al+1+⋯+Ar=0.
Constraints
- 1≤N≤30
- 1≤K≤N2
- All values in input are integers.
Input is given from Standard Input in the following format:
N K
Output
Print the number of different sequences that satisfy the conditions in Problem Statement.
The answer always fits into the signed 64-bit integer type.
1 1
2
For N=1,K=1, two sequences below satisfy the conditions:
- A=(+1,−1)
- A=(−1,+1)
2 3
2
For N=2,K=3, two sequences below satisfy the conditions:
- A=(+1,−1,−1,+1)
- A=(−1,+1,+1,−1)
3 7
6
For N=3,K=7, six sequences below satisfy the conditions:
- A=(+1,−1,+1,−1,−1,+1)
- A=(+1,−1,−1,+1,+1,−1)
- A=(+1,−1,−1,+1,−1,+1)
- A=(−1,+1,+1,−1,+1,−1)
- A=(−1,+1,+1,−1,−1,+1)
- A=(−1,+1,−1,+1,+1,−1)
8 24
568
30 230
761128315856702
25 455
0
For N=25,K=455, no sequences satisfy the conditions.