아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Math is Fun

시간 제한4초메모리 제한256 MB

요약
배열 A의 모든 연속 부분배열 S에 대해 GCD(S) * LCM(S)^2의 합을 10^9+7로 나눈 나머지를 구합니다. N은 100 이하, 각 값은 1000 이하입니다.
난이도

보통10점 중 7점

유형
수학, 정수론, 동적 계획법, 해시맵
정답자
아직 제출이 없습니다

문제

Boy XYZ introduced a simple math function called GLL\mathit{GLL} for an array of integers S=a_1,a_2,…,a_nS = \\{a\_1, a\_2, \ldots, a\_n\\}:

GLL(S)=GCD(S)⋅ LCM(S)⋅LCM(S).\mathit{GLL}(S) = \mathit{GCD}(S) \cdot   \mathit{LCM}(S) \cdot \mathit{LCM}(S)\text{.}

Here, GCD(S)=GCD(a_1,a_2,…,a_n)\mathit{GCD}(S) = \mathit{GCD}(a\_1, a\_2, \ldots, a\_n) is the greatest common divisor of integers a_1,a_2,…,a_na\_1, a\_2, \ldots, a\_n, and LCM(S)=LCM(a_1,a_2,…,a_n)\mathit{LCM}(S) = \mathit{LCM}(a\_1, a\_2, \ldots, a\_n) is the least common multiple of integers a_1,a_2,…,a_na\_1, a\_2, \ldots, a\_n.

For an array consisting of one element, GCD\mathit{GCD} and LCM\mathit{LCM} are equal to that element. For example, GCD\mathit{GCD} of S=xS = \\{x\\} is xx. Consider the LCM\mathit{LCM} and GCD\mathit{GCD} of an empty array as 00.

Now, XYZ is interested in finding the sum of GLL\mathit{GLL} values of all subarrays for a given array AA, but he finds the problem very hard. Help him calculate the following:

Answer=∑_S⊆AGLL(S).\mathit{Answer} = \sum\_{S \subseteq A}\mathit{GLL}(S)\text{.}

Here, S⊆AS \subseteq A means that SS is a subarray of AA, that is, the array AA with some (possibly zero, possibly all) elements removed.

As the answer can be very large, print it modulo 109+710^9 + 7.

입력

The first line of input contains TT, the number of test cases (1≤T≤501 \le T \le 50). TT test cases follow.

The first line of each test case contains NN, the number of elements in AA (1≤N≤1001 \le N \le 100). The next line contains NN space-separated positive integers: the elements of AA. The numbers in the array are in the range \[1,1000]\[1, 1000].

출력

For each test case, print the answer on a separate line.

예제1

  1. 예제 1

    입력
    2
    2
    2 3
    3
    2 4 10
    
    예상 출력
    71
    2904