CF1985B.Maximum Multiple Sum

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Maximum Multiple Sum

Given an integer nn, find an integer xx such that:

  • 2xn2 \leq x \leq n.
  • The sum of multiples of xx that are less than or equal to nn is maximized. Formally, x+2x+3x++kxx + 2x + 3x + \dots + kx where kxnkx \leq n is maximized over all possible values of xx.

Input

The first line contains tt (1t1001 \leq t \leq 100) — the number of test cases.

Each test case contains a single integer nn (2n1002 \leq n \leq 100).

Output

For each test case, output an integer, the optimal value of xx. It can be shown there is only one unique answer.

Note

For n=3n = 3, the possible values of xx are 22 and 33. The sum of all multiples of 22 less than or equal to nn is just 22, and the sum of all multiples of 33 less than or equal to nn is 33. Therefore, 33 is the optimal value of xx.

For n=15n = 15, the optimal value of xx is 22. The sum of all multiples of 22 less than or equal to nn is 2+4+6+8+10+12+14=562 + 4 + 6 + 8 + 10 + 12 + 14 = 56, which can be proven to be the maximal over all other possible values of xx.

Samples

2
3
15
3
2

在线编程 IDE

建议全屏模式获得最佳体验