#C2861. Magic Card Trick

    ID: 46224 Type: Default 1000ms 256MiB

Magic Card Trick

Magic Card Trick

This problem involves performing a "magic card trick" using mathematical operations. You are given T test cases. In each test case, you are provided with N decks of cards and each deck has a certain number of cards. Your task is to compute two values:

  • R: the maximum possible value such that every deck's card count is divisible by R. That is, \(R = \gcd(a_1, a_2, \dots, a_N)\).
  • M: the minimum number of audience members, computed as \(M = \frac{\text{total cards}}{R}\), where the \(\text{total cards}\) is the sum of all cards in the decks.

You need to output \(R\) and \(M\) for each test case.

inputFormat

The input is read from standard input (stdin) and is structured as follows:

  1. The first line contains an integer T, the number of test cases.
  2. For each test case:
    1. The first line contains an integer N, the number of decks.
    2. The second line contains N space-separated integers representing the number of cards in each deck.

outputFormat

For each test case, output a single line containing two space-separated integers: R and M, where:

  • R = \gcd(a_1, a_2, \dots, a_N)
  • M = \frac{a_1+a_2+\cdots+a_N}{R}

The output is written to standard output (stdout).

## sample
1
2
12 15
3 9

</p>