Count how many length- integers can be rearranged into a palindrome that is divisible by .
You are given two integers and .
Count how many positive integers with exactly digits are good.
An -digit integer is called good if its digits can be rearranged to form a palindrome that is divisible by .
Two integers are considered different if their decimal representations are different, even if they contain the same digits in a different order.
0.n and k.n digits.0 to 9).Two integers n and k.
The count of good integers with exactly n digits.
Example 1
Input
n = 3, k = 2
Output
9
Explanation
The good 3-digit integers are exactly those whose digits can be rearranged into an even palindrome divisible by 2, such as 202, 212, 222, 232, 242, 252, 262, 272, and 282. All of them have digit multiset {2, x, 2} with a valid palindrome arrangement divisible by 2, giving a total of 9.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.