#P7273. ix35 的等差数列
ix35 的等差数列
Background
An arithmetic progression is a sequence in which, starting from the second term, the difference between each term and the previous term is the same constant, and this constant is called the common difference. In particular, a sequence with only one term is also considered an arithmetic progression, and its common difference is regarded as .
Problem Description
You are given a positive integer sequence with terms, satisfying .
You may perform some modifications. In one modification, you can change any term of the sequence to any positive integer .
Find the minimum number of modifications needed to turn the original sequence into an arithmetic progression whose common difference is a non-negative integer.
Input Format
The first line contains two integers .
The next line contains integers .
Output Format
Output one integer on a single line, the required answer.
6 1000
1 2 999 4 72 6
2
10 2
2 1 2 2 1 1 2 2 2 2
3
1 1
1
0
Hint
Sample Explanation #1
Change to , and change to .
Constraints
This problem uses bundled testdata.
- Subtask 1 ( points): , .
- Subtask 2 ( points): .
- Subtask 3 ( points): .
- Subtask 4 ( points): .
- Subtask 5 ( points): no special constraints.
For of the testdata, .
Original idea: ix35.
Translated by ChatGPT 5