-1
The number 1 can be written as sum of fractions of the form 1/p (where p>1). There are different ways to write it. You will be given an integer k which denotes the number of fractions to be used to get the sum as 1. You need to find the largest possible value of p among all possible ways. See sample input for clarity
Input Format:
The first line contains number of test cases t. Then t lines follow each having a single integer k.
Output:
You need to print the largest value of p modulo 10^9 + 7.
Constraints:
1<=t<=10^5
2<=k<=10^6
Sample Input --------------- Sample Output
2 2
2 6
3
Explanation There is only one way to write '1' as sum of two fractions. 1/2 + 1/2. hence the largest value is 2. In the second test case, the only possible ways as sum of three fractions are:
1/3, 1/3, 1/3
1/6, 1/2, 1/3
1/4, 1/4, 1/2
Among these the second representation has the largest denominator which is '6' and hence the answer.
Ah, so the trivial solution of p = k is suboptimal.
p modulo 10^9 + 7
not sure I get this though – Cruncher – 2014-01-17T13:40:16.360what does
2 2\n2 6\n3
mean... – mniip – 2014-01-17T13:45:18.977@mniip the left is input. The right is output. The first input number is the number of cases, so the 2 matches the 2, and the 3 matches the 6. The first 2 just says there's 2 cases. – Cruncher – 2014-01-17T15:08:51.693
wouldn't that be
2\n2 2\n3 6
then? – mniip – 2014-01-17T15:12:22.737@mniip I can see how it's confusing, but that would imply that the output has to start with a newline. They're 2 separate boxes really, the fact that they're side by side is irrelevant. One is input and one is output – Cruncher – 2014-01-17T15:14:13.260