2549. Count Distinct Numbers on Board Easy
1/**
2 * [2549] Count Distinct Numbers on Board
3 *
4 * You are given a positive integer n, that is initially placed on a board. Every day, for 10^9 days, you perform the following procedure:
5 *
6 * For each number x present on the board, find all numbers 1 <= i <= n such that x % i == 1.
7 * Then, place those numbers on the board.
8 *
9 * Return the number of distinct integers present on the board after 10^9 days have elapsed.
10 * Note:
11 *
12 * Once a number is placed on the board, it will remain on it until the end.
13 * % stands for the modulo operation. For example, 14 % 3 is 2.
14 *
15 *
16 * <strong class="example">Example 1:
17 *
18 * Input: n = 5
19 * Output: 4
20 * Explanation: Initially, 5 is present on the board.
21 * The next day, 2 and 4 will be added since 5 % 2 == 1 and 5 % 4 == 1.
22 * After that day, 3 will be added to the board because 4 % 3 == 1.
23 * At the end of a billion days, the distinct numbers on the board will be 2, 3, 4, and 5.
24 *
25 * <strong class="example">Example 2:
26 *
27 * Input: n = 3
28 * Output: 2
29 * Explanation:
30 * Since 3 % 2 == 1, 2 will be added to the board.
31 * After a billion days, the only two distinct numbers on the board are 2 and 3.
32 *
33 *
34 * Constraints:
35 *
36 * 1 <= n <= 100
37 *
38 */
39pub struct Solution {}
40
41// problem: https://leetcode.com/problems/count-distinct-numbers-on-board/
42// discuss: https://leetcode.com/problems/count-distinct-numbers-on-board/discuss/?currentPage=1&orderBy=most_votes&query=
43
44// submission codes start here
45
46impl Solution {
47 pub fn distinct_integers(n: i32) -> i32 {
48 0
49 }
50}
51
52// submission codes end
53
54#[cfg(test)]
55mod tests {
56 use super::*;
57
58 #[test]
59 fn test_2549() {
60 }
61}
62
Back
© 2025 bowen.ge All Rights Reserved.