Forming Groups
시간 제한5초메모리 제한1024 MB
고정된 n-1명 사이에 자신을 넣고 n의 약수 k를 골라, 가장 큰 그룹 합과 가장 작은 그룹 합의 비율을 최소로 만든다.
문제
There are students, numbered from to , who need to form groups for the upcoming hackathon. You are student , the captain of the students. Student has skill level .
Students to 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 , or to the right of student . You cannot change the order of the students.
You can also choose the number of groups ( and must be a divisor of ) to participate in the hackathon. The groups will be numbered from to . After you have chosen your position and the value of , the students will be grouped as follows:
- The first student from the left will be assigned to group .
- The second student from the left will be assigned to group .
- The -th student from the left will be assigned to group .
- The -th student from the left will be assigned to group .
- The -th student from the left will be assigned to group .
- The -th student from the left will be assigned to group .
Formally, for each () and for each (), the -th student from the left will be assigned to group . 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 optimally, you want to minimize the ratio where
- is the skill level of the group with the largest skill level, and
- is the skill level of the group with the smallest skill level.
입력
The first line of input contains one integer () representing the number of test cases. After that, test cases follow. Each of them is presented as follows.
The first line of a test case contains two integers and (; ). The next line contains integers ( for all ).
The sum of across all test cases in one input file does not exceed .
출력
For each test case, output one line containing two positive integers and such that the minimum ratio is . The fraction should be irreducible. In other words, and should be coprime.