P17617 [CodeChef] TWONUMBERS
普及
题目描述

Given two positive integers a and b, we define $f(a, b) = \text{lcm}(a, b) - \gcd(a, b)$, where $\text{lcm}$ denotes the [lowest common multiple] and $\gcd$ denotes the [greatest common divisor].

Chef has a positive integer N. He wonders, what is the maximum value of f(a, b) over all pairs (a, b) such that a and b are positive integers, and a + b = N?

------ Input Format ------

  • The first line of input will contain an integer T — the number of test cases. The description of T test cases follows.
  • The first line of each test case contains an integer N, as described in the problem statement.

------ Output Format ------

For each test case, output the maximum value of f(a, b) that can be obtained while satisfying the conditions on a and b.

------ Constraints ------

$1 ≤ T ≤ 10^{5}$
$2 ≤ N ≤ 10^{9}$

----- Sample Input 1 ------
3
3
4
6

----- Sample Output 1 ------
1
2
4

----- explanation 1 ------
Test case $1$: There are two possible pairs of $(a, b)$: $(1, 2)$ and $(2, 1)$. For both of these pairs, we have $\text{lcm}(a, b) = 2$ and $\gcd(a, b) = 1$, which gives $f(a, b) = 1$.

Test case $2$: For $(1, 3)$, we have $\text{lcm}(1, 3) = 3$ and $\gcd(1, 3) = 1$, giving $f(1, 3) = 3 - 1 = 2$. It can be shown that this is the maximum possible value of $f(a, b)$ that can be obtained while satisfying the above conditions.

Test case $3$: For $(1, 5)$, we have $\text{lcm}(1, 5) = 5$ and $\gcd(1, 5) = 1$, giving $f(1, 5) = 5 - 1 = 4$. It can be shown that this is the maximum possible value of $f(a, b)$ that can be obtained while satisfying the above conditions.

输入格式

见题面

输出格式

见题面

样例输入
3 3 4 6
样例输出
1 2 4