시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB70623717330.404%

문제

N개의 자연수로 이루어진 수열이 있다. 이 수열은 1부터 N까지 자연수로 이루어져 있으며, 각 숫자는 한 번씩 등장한다.

첫 번째 숫자가 두 번째 숫자보다 크고, 수열에서 더 먼저 등장하는 숫자의 쌍을 혼돈의 쌍이라고 한다.

수열의 혼란도는 수열의 혼돈의 쌍의 개수이다. 예를 들어, (1, 4, 3, 2)의 혼란도는 3이다. 그 이유는 혼돈의 쌍이 (4, 3), (4, 2), (3, 2)로 세 개 있기 때문이다.

N이 주어졌을 때, 혼란도가 C인 수열의 개수를 구하는 프로그램을 작성하시오.

입력

첫째 줄에 N과 C가 주어진다. (1 ≤ N ≤ 1000, 0 ≤ C ≤ 10000)

출력

첫째 줄에 혼란도가 C이고 길이가 N인 수열의 개수를 1,000,000,007로 나눈 나머지를 출력한다.

예제 입력 1

10 1

예제 출력 1

9

예제 입력 2

4 3

예제 출력 2

6

예제 입력 3

9 13

예제 출력 3

17957
W3sicHJvYmxlbV9pZCI6IjMwMzciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQ2M2NcdWI3ODAiLCJkZXNjcmlwdGlvbiI6IjxwPk5cdWFjMWNcdWM3NTggXHVjNzkwXHVjNWYwXHVjMjE4XHViODVjIFx1Yzc3NFx1YjhlOFx1YzViNFx1YzljNCBcdWMyMThcdWM1ZjRcdWM3NzQgXHVjNzg4XHViMmU0LiBcdWM3NzQgXHVjMjE4XHVjNWY0XHVjNzQwIDFcdWJkODBcdWQxMzAgTlx1YWU0Y1x1YzljMCBcdWM3OTBcdWM1ZjBcdWMyMThcdWI4NWMgXHVjNzc0XHViOGU4XHVjNWI0XHVjODM4IFx1Yzc4OFx1YzczY1x1YmE3MCwgXHVhYzAxIFx1YzIyYlx1Yzc5MFx1YjI5NCBcdWQ1NWMgXHViYzg4XHVjNTI5IFx1YjRmMVx1YzdhNVx1ZDU1Y1x1YjJlNC48XC9wPlx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