시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 6 | 1 | 1 | 25.000% |
Pesho is crypting a sequence of N numbers where each integer from 1 to N appears exactly once. He is using the following algorithm:
Let us see how Pesho should crypt the sequence {4, 1, 3, 2}:
Pesho obtains the new sequence {7, 2, 5, 3}.
{7}, {2}, {5}, {3}, {7, 2}, {2, 5}, {5, 3}, {7, 2, 5}, {2, 5, 3}, {7, 2, 5 ,3}
Pesho removes all subsequences with less than K=2 elements and for each of the rest he computes the product of the smallest K=2 elements.
He writes the numbers {14, 10, 15, 10, 6, 6}
Pesho quickly figured out that the algorithm is much better than he expected. He cannot always decrypt the code unambiguously.
Write a program crypto, which given a code calculates the number of possible initial sequences. Find the answer modulo 1 000 000 007.
The first line contains the positive integers N, K and P.
Print the number of possible initial sequences with code “N K P”. Print the answer modulo 1 000 000 007.
3 2 3
2
The sequences {1, 3, 2} and {2, 3, 1} will be crypted as “3 2 3”.
4 2 4
12
The sequences are {1, 2, 4, 3}, {1, 3, 2, 4}, {1, 4, 2, 3}, {2, 1, 4, 3}, {2, 3, 1, 4}, {2, 4, 1, 3}, {3, 1, 4, 2}, {3, 2, 4, 1}, {3, 4, 1, 2}, {3, 4, 2, 1}, {4, 1, 3, 2}, {4, 2, 3, 1}.