Forming Groups

시간 제한5초메모리 제한1024 MB

요약
고정된 n-1명 사이에 자신을 넣고 n의 약수 k를 골라, 가장 큰 그룹 합과 가장 작은 그룹 합의 비율을 최소로 만든다.
난이도

어려움10점 중 8점

유형
정수론, 누적 합, 수학, 완전 탐색
정답자
아직 제출이 없습니다

문제

There are nn students, numbered from 11 to nn, who need to form groups for the upcoming hackathon. You are student 11, the captain of the students. Student ii has skill level a_ia\_i.

Students 22 to nn 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 22, or to the right of student nn. You cannot change the order of the n−1n - 1 students.

You can also choose the number of groups kk (k>1k > 1 and kk must be a divisor of nn) to participate in the hackathon. The groups will be numbered from 11 to kk. After you have chosen your position and the value of kk, the students will be grouped as follows:

  • The first student from the left will be assigned to group 11.
  • The second student from the left will be assigned to group 22.
  • …\dots
  • The kk-th student from the left will be assigned to group kk.
  • The (k+1)(k + 1)-th student from the left will be assigned to group 11.
  • The (k+2)(k + 2)-th student from the left will be assigned to group 22.
  • …\dots
  • The nn-th student from the left will be assigned to group kk.

Formally, for each jj (1≤j≤k1 ≤ j ≤ k) and for each ii (0≤i<n/k0 ≤ i < n/k), the (i×k+j)(i \times k +j)-th student from the left will be assigned to group jj. 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 kk optimally, you want to minimize the ratio x_max⁡/x_min⁡x\_\max/x\_\min where

  • x_max⁡x\_\max is the skill level of the group with the largest skill level, and
  • x_min⁡x\_\min is the skill level of the group with the smallest skill level.

입력

The first line of input contains one integer tt (1≤t≤100,0001 ≤ t ≤ 100\\, 000) representing the number of test cases. After that, tt test cases follow. Each of them is presented as follows.

The first line of a test case contains two integers nn and a_1a\_1 (2≤n≤1062 ≤ n ≤ 10^6; 1≤a_1≤10001 ≤ a\_1 ≤ 1000). The next line contains n−1n - 1 integers a_2,a_3,…,a_na\_2, a\_3, \dots , a\_n (1≤a_i≤10001 ≤ a\_i ≤ 1000 for all ii).

The sum of nn across all test cases in one input file does not exceed 10610^6.

출력

For each test case, output one line containing two positive integers pp and qq such that the minimum ratio is p/qp/q. The fraction p/qp/q should be irreducible. In other words, pp and qq should be coprime.

예제1

  1. 예제 1

    입력
    2
    4 1
    2 1 2
    3 10
    4 3
    
    예상 출력
    1 1
    10 3