#P1384. 幸运数与排列
幸运数与排列
Description
A number is a lucky number if and only if it consists only of the digits and , for example , , .
Among all permutations of to in lexicographical order, consider the -th smallest permutation. Count how many indices such that both the position and the element at position are lucky numbers.
Input Format
One line containing two integers , .
Output Format
Output a single integer representing the answer. If the -th smallest permutation does not exist, output .
7 4
1
4 7
1
Hint
Sample 1 Explanation: The permutation is 1, 2, 3, 4, 6, 7, 5.
Sample 2 Explanation: The permutation is: 2, 1, 3, 4.
Constraints:
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that .
Translated by ChatGPT 5
京公网安备 11011102002149号