#P10822. [EC Final 2020] Prof. Pang's sequence
[EC Final 2020] Prof. Pang's sequence
题目描述
Prof. Pang is given a fixed sequence and queries.
Each query is specified by two integers and satisfying . For each query, you should answer the number of pairs of integers such that and the number of distinct integers in is odd.
输入格式
The first line contains a single integer ().
The next line contains integers ( for all ) separated by single spaces.
The next line contains a single integer ().
Each of the next lines contains two integers and () separated by a single space denoting a query.
输出格式
For each query, output one line containing the answer to that query.
5
1 2 3 2 1
5
1 5
2 4
1 3
2 5
4 4
10
3
4
6
1
5
2 3 5 1 5
5
2 3
1 1
1 3
2 5
2 4
2
1
4
6
4
10
2 8 5 1 10 5 9 9 3 5
10
6 8
1 2
3 5
5 7
1 7
3 9
4 9
1 4
3 7
2 5
4
2
4
4
16
16
12
6
9
6