#P14199. [ICPC 2024 Hangzhou R] Make It Divisible
[ICPC 2024 Hangzhou R] Make It Divisible
题目描述
Given a sequence of length containing positive integers, we say an interval () is a if there exists an integer such that and for all , is divisible by . We say the whole sequence is a if for all , is a divisible interval.
Given another sequence of length and an integer , find all integers such that and the sequence is a divisible sequence. As the number of such integers might be large, you just need to output the number and the sum of all such integers.
输入格式
There are multiple test cases. The first line of the input contains an integer () indicating the number of test cases. For each test case:
The first line contains two integers and (, ).
The second line contains integers ().
It's guaranteed that the sum of of all test cases does not exceed .
输出格式
For each test case output one line containing two integers separated by a space, where the first integer is the number of valid , and the second integer is the sum of all valid .
3
5 10
7 79 1 7 1
2 1000000000
1 2
1 100
1000000000
3 8
0 0
100 5050
提示
For the first sample test case, , and are valid.
For the third sample test case, all are valid.