Codeforces Round 976 (Div. 2) and Divide By Zero 9.0
B
Brightness Begins
Codeforces
1200
原题
← AC →
翻译中…

Imagine you have $n$ light bulbs numbered $1, 2, \ldots, n$. Initially, all bulbs are on. To flip the state of a bulb means to turn it off if it used to be on, and to turn it on otherwise.

翻译中…

Next, you do the following:

翻译中…
  • for each $i = 1, 2, \ldots, n$, flip the state of all bulbs $j$ such that $j$ is divisible by $i^\dagger$.
翻译中…

After performing all operations, there will be several bulbs that are still on. Your goal is to make this number exactly $k$.

翻译中…

Find the smallest suitable $n$ such that after performing the operations there will be exactly $k$ bulbs on. We can show that an answer always exists.

翻译中…

$^\dagger$ An integer $x$ is divisible by $y$ if there exists an integer $z$ such that $x = y\cdot z$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The only line of each test case contains a single integer $k$ ($1 \le k \le 10^{18}$).

翻译中…

Output

翻译中…

For each test case, output $n$ — the minimum number of bulbs.

翻译中…

Note

翻译中…

In the first test case, the minimum number of bulbs is $2$. Let's denote the state of all bulbs with an array, where $1$ corresponds to a turned on bulb, and $0$ corresponds to a turned off bulb. Initially, the array is $[1, 1]$.

翻译中…
  • After performing the operation with $i = 1$, the array becomes $[\underline{0}, \underline{0}]$.
  • After performing the operation with $i = 2$, the array becomes $[0, \underline{1}]$.
翻译中…

In the end, there are $k = 1$ bulbs on. We can also show that the answer cannot be less than $2$.

翻译中…

In the second test case, the minimum number of bulbs is $5$. Initially, the array is $[1, 1, 1, 1, 1]$.

翻译中…
  • After performing the operation with $i = 1$, the array becomes $[\underline{0}, \underline{0}, \underline{0}, \underline{0}, \underline{0}]$.
  • After performing the operation with $i = 2$, the array becomes $[0, \underline{1}, 0, \underline{1}, 0]$.
  • After performing the operation with $i = 3$, the array becomes $[0, 1, \underline{1}, 1, 0]$.
  • After performing the operation with $i = 4$, the array becomes $[0, 1, 1, \underline{0}, 0]$.
  • After performing the operation with $i = 5$, the array becomes $[0, 1, 1, 0, \underline{1}]$.
翻译中…

In the end, there are $k = 3$ bulbs on. We can also show that the answer cannot be smaller than $5$.

翻译中…

样例

Input #1
3
1
3
8
Output #1
2
5
11
InputCopy OutputCopy
题目信息
题号
2020B
时间限制
1 s
内存限制
256 MB
标签
二分
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。