Class Solution
java.lang.Object
g2501_2600.s2549_count_distinct_numbers_on_board.Solution
2549 - Count Distinct Numbers on Board.<p>Easy</p>
<p>You are given a positive integer <code>n</code>, that is initially placed on a board. Every day, for <code>10<sup>9</sup></code> days, you perform the following procedure:</p>
<ul>
<li>For each number <code>x</code> present on the board, find all numbers <code>1 <= i <= n</code> such that <code>x % i == 1</code>.</li>
<li>Then, place those numbers on the board.</li>
</ul>
<p>Return <em>the number of <strong>distinct</strong> integers present on the board after</em> <code>10<sup>9</sup></code> <em>days have elapsed</em>.</p>
<p><strong>Note:</strong></p>
<ul>
<li>Once a number is placed on the board, it will remain on it until the end.</li>
<li><code>%</code> stands for the modulo operation. For example, <code>14 % 3</code> is <code>2</code>.</li>
</ul>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> n = 5</p>
<p><strong>Output:</strong> 4</p>
<p><strong>Explanation:</strong> Initially, 5 is present on the board.</p>
<p>The next day, 2 and 4 will be added since 5 % 2 == 1 and 5 % 4 == 1.</p>
<p>After that day, 3 will be added to the board because 4 % 3 == 1.</p>
<p>At the end of a billion days, the distinct numbers on the board will be 2, 3, 4, and 5.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> n = 3</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> Since 3 % 2 == 1, 2 will be added to the board. After a billion days, the only two distinct numbers on the board are 2 and 3.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= n <= 100</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
distinctIntegers
public int distinctIntegers(int n)
-