#P10998. [2015杭电多校]GCD
[2015杭电多校]GCD
GCD
Problem Description
Give you a sequence of integers : . There are queries. For each query you have to calculate and count the number of pairssuch that equal .
Input
The first line of input contains a number , which stands for the number of test cases you need to solve. The first line of each case contains a number , denoting the number of integers. The second line contains integers, . The third line contains a number , denoting the number of queries. For the next lines, i-th line contains two number , stand for the , stand for the i-th queries.
Output
For each case, you need to output “Case #:t” at the beginning.(with quotes, means the number of the test case, begin from 1). For each query, you need to output the two numbers in a line. The first number stands for and the second number stands for the number of pairs such that equal .
Sample Input
1
5
1 2 4 6 7
4
1 5
2 4
3 4
4 4
Sample Output
Case #1:
1 8
2 4
2 4
6 1
Author
HIT
Source
2016 Multi-University Training Contest 1