Question: C + + An array a 1 , a 2 , dots, a n is good if and only if for every subsegment 1 l

C++
An array a1,a2,dots,an is good if and only if for every subsegment 1lrn, the following holds:
al+al+1+dots+ar=12(al+ar)*(r-l+1).
You are given an array of integers a1,a2,dots,an. In one operation, you can replace any one element of this array with any real number.
Find the minimum number of operations you need to make this array good.
Input
The first line of input contains one integer t(1t100) : the number of test cases.
Each of the next t lines contains the description of a test case.
In the first line you are given one integer n(1n70) : the number of integers in the array.
The second line contains n integers a1,a2,dots,an(-100ai100) : the initial array.
Output
For each test case, print one integer: the minimum number of elements that you need to replace to make the given array good.
Example
0
2
0
3
0
 C++ An array a1,a2,dots,an is good if and only if for

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!