| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 5 초 | 1024 MB | 141 | 53 | 49 | 39.200% |
There are $n$ students, numbered from 1ドル$ to $n,ドル who need to form groups for the upcoming hackathon. You are student 1ドル,ドル the captain of the students. Student $i$ has skill level $a_i$.
Students 2ドル$ to $n$ are standing in a line from left to right in order. You can choose to stand in between any two students, to the left of student 2ドル,ドル or to the right of student $n$. You cannot change the order of the $n - 1$ students.
You can also choose the number of groups $k$ ($k > 1$ and $k$ must be a divisor of $n$) to participate in the hackathon. The groups will be numbered from 1ドル$ to $k$. After you have chosen your position and the value of $k,ドル the students will be grouped as follows:
Formally, for each $j$ (1ドル ≤ j ≤ k$) and for each $i$ (0ドル ≤ i < n/k$), the $(i \times k +j)$-th student from the left will be assigned to group $j$. It can be shown that each student will be assigned to exactly one group and all the groups have the same number of students.
The skill level of a group is the sum of the skill levels of the students inside the group. By choosing where you stand as well as the number of groups $k$ optimally, you want to minimize the ratio $x_\max/x_\min$ where
The first line of input contains one integer $t$ (1ドル ≤ t ≤ 100,円 000$) representing the number of test cases. After that, $t$ test cases follow. Each of them is presented as follows.
The first line of a test case contains two integers $n$ and $a_1$ (2ドル ≤ n ≤ 10^6$; 1ドル ≤ a_1 ≤ 1000$). The next line contains $n - 1$ integers $a_2, a_3, \dots , a_n$ (1ドル ≤ a_i ≤ 1000$ for all $i$).
The sum of $n$ across all test cases in one input file does not exceed 10ドル^6$.
For each test case, output one line containing two positive integers $p$ and $q$ such that the minimum ratio is $p/q$. The fraction $p/q$ should be irreducible. In other words, $p$ and $q$ should be coprime.
2 4 1 2 1 2 3 10 4 3
1 1 10 3
In the first test case, by standing between students 2ドル$ and 3ドル$ (or between students 3ドル$ and 4ドル$) and choosing $k = 2,ドル group 1ドル$ will have the skill level 2ドル + 1$ and group 2ドル$ will have the skill level 1ドル + 2,ドル thus the ratio is 1ドル/1$.
In the second test case, the only choice for the value of $k$ is 3ドル$.