3272. Find the Count of Good Integers Hard

@problem@discussion
#Hash Table#Math#Combinatorics#Enumeration



1/**
2 * [3272] Find the Count of Good Integers
3 *
4 * You are given two positive integers n and k.
5 * An integer x is called k-palindromic if:
6 * 
7 * 	x is a <span data-keyword="palindrome-integer">palindrome</span>.
8 * 	x is divisible by k.
9 * 
10 * An integer is called good if its digits can be rearranged to form a k-palindromic integer. For example, for k = 2, 2020 can be rearranged to form the k-palindromic integer 2002, whereas 1010 cannot be rearranged to form a k-palindromic integer.
11 * Return the count of good integers containing n digits.
12 * Note that any integer must not have leading zeros, neither before nor after rearrangement. For example, 1010 cannot be rearranged to form 101.
13 *  
14 * <strong class="example">Example 1:
15 * <div class="example-block">
16 * Input: <span class="example-io">n = 3, k = 5</span>
17 * Output: <span class="example-io">27</span>
18 * Explanation:
19 * Some of the good integers are:
20 * 
21 * 	551 because it can be rearranged to form 515.
22 * 	525 because it is already k-palindromic.
23 * </div>
24 * <strong class="example">Example 2:
25 * <div class="example-block">
26 * Input: <span class="example-io">n = 1, k = 4</span>
27 * Output: <span class="example-io">2</span>
28 * Explanation:
29 * The two good integers are 4 and 8.
30 * </div>
31 * <strong class="example">Example 3:
32 * <div class="example-block">
33 * Input: <span class="example-io">n = 5, k = 6</span>
34 * Output: <span class="example-io">2468</span>
35 * </div>
36 *  
37 * Constraints:
38 * 
39 * 	1 <= n <= 10
40 * 	1 <= k <= 9
41 * 
42 */
43pub struct Solution {}
44
45// problem: https://leetcode.com/problems/find-the-count-of-good-integers/
46// discuss: https://leetcode.com/problems/find-the-count-of-good-integers/discuss/?currentPage=1&orderBy=most_votes&query=
47
48// submission codes start here
49
50impl Solution {
51    pub fn count_good_integers(n: i32, k: i32) -> i64 {
52        
53    }
54}
55
56// submission codes end
57
58#[cfg(test)]
59mod tests {
60    use super::*;
61
62    #[test]
63    fn test_3272() {
64    }
65}
66


Back
© 2025 bowen.ge All Rights Reserved.