#P8319. 『JROI-4』分数

    ID: 5790 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>数学2022洛谷原创素数判断,质数,筛法洛谷月赛

『JROI-4』分数

Description

The process of an “xx-person petition” can be seen as a function f(x)f(x):

There is a fraction 0x\frac{0}{x}. Repeat the following steps until this fraction becomes 11:

  1. Add 11 to the numerator.
  2. If this fraction can be reduced, reduce it to its simplest form.

Now Xiao D gives you TT test cases. In each test case, you are given nn. You need to find, for 1xn1 \le x \le n, the maximum number of operations of f(x)f(x).

But he is too weak and cannot do it. Can you help him?

Input Format

The first line contains a positive integer TT.

The next TT lines each contain a positive integer nn.

Output Format

Output TT lines. Each line contains an integer ss, meaning the maximum number of operations of f(x)f(x) for 1xn1 \le x \le n.

5
1
2
5
8
114514
1
2
5
7
114493

Hint

Sample Explanation

f(1)=1,f(2)=2,f(3)=3,f(4)=3,f(5)=5f(1)=1,f(2)=2,f(3)=3,f(4)=3,f(5)=5.

I also want to list larger values of f(x)f(x), but there is not enough space.

Constraints

For all testdata, 1T5×1051 \le T \le 5 \times 10^5, 1n2×1061 \le n \le 2 \times 10^6.

Parts not filled in the Subtasks table mean they are the same as the constraints for all data.

Subtask ID Range of TT Range of nn Special Property Score
Subtask 11 T3T \le 3 n10n \le 10 1010
Subtask 22 T5T \le 5 n103n \le 10^3 3030
Subtask 33 nn is prime. 1010
Subtask 44 n5×105n \le 5 \times 10^5 2020
Subtask 55 3030

Translated by ChatGPT 5