luogu#P9882. [EC Final 2021] Vision Test
[EC Final 2021] Vision Test
题目描述
Prof. Pang has an extraordinary vision. He can see the pixels on a 4K monitor. To test Prof. Pang's vision, Prof. Shou will show Prof. Pang several pixels and let Prof. Pang guess a straight line that contains these pixels. Given pixels with coordinates (), Prof. Pang must find nonnegative integers and (which represent the line ) such that for all .
Prof. Shou will ask Prof. Pang multiple questions. They are given as follows: Prof. Shou has a fixed array . For each question, Prof. Shou chooses a range in the array, . Then he defines for and asks Prof. Pang to answer the question for the pixels .
Please help Prof. Pang answer all the questions. For each question, output the answer with the minimum in lexical order.
It is guaranteed that the answer exists when Prof. Pang chooses the whole array . So the answer always exists when Prof. Pang chooses an interval of this array.
输入格式
The first line contains a single integer () denoting the number of test cases.
For each test case, the first line contains an integer (). The second line contains numbers ().
The next line contains an integer () denoting the number of questions.
Each of the following lines contains two integers ().
It is guaranteed that the sum of over all test cases will not exceed and that the sum of over all test cases will not exceed .
输出格式
In the order of input, output one line with three integers denoting the answer for each question.
题目大意
给定一个长度为 的数组 ,接下来你有 次询问。
第 次询问给出一个区间 ,设 ,你提取出 数组下标在 之间的区间 。
考虑 个点 。你需要找到一条直线的三个整数参数 ,满足 。若有多条这样的直线,输出 三元组字典序最小的一个。
保证对于整个数组,即 的询问一定存在一组合法的解。
,多组询问。
3
5
1 1 2 2 2
4
1 5
1 1
3 5
2 3
5
1 2 3 4 6
3
1 5
2 4
3 5
3
0 3 5
1
1 3
1 4 3
0 1 1
0 2 1
1 1 1
5 4 4
1 2 1
3 6 2
5 1 2