1922. Count Good Numbers Medium
1/**
2 * [1922] Count Good Numbers
3 *
4 * A digit string is good if the digits (0-indexed) at even indices are even and the digits at odd indices are prime (2, 3, 5, or 7).
5 *
6 * For example, "2582" is good because the digits (2 and 8) at even positions are even and the digits (5 and 2) at odd positions are prime. However, "3245" is not good because 3 is at an even index but is not even.
7 *
8 * Given an integer n, return the total number of good digit strings of length n. Since the answer may be large, return it modulo 10^9 + 7.
9 * A digit string is a string consisting of digits 0 through 9 that may contain leading zeros.
10 *
11 * Example 1:
12 *
13 * Input: n = 1
14 * Output: 5
15 * Explanation: The good numbers of length 1 are "0", "2", "4", "6", "8".
16 *
17 * Example 2:
18 *
19 * Input: n = 4
20 * Output: 400
21 *
22 * Example 3:
23 *
24 * Input: n = 50
25 * Output: 564908303
26 *
27 *
28 * Constraints:
29 *
30 * 1 <= n <= 10^15
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/count-good-numbers/
36// discuss: https://leetcode.com/problems/count-good-numbers/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn count_good_numbers(n: i64) -> i32 {
42 0
43 }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_1922() {
54 }
55}
56
Back
© 2025 bowen.ge All Rights Reserved.