#K36752. Sequence Division Challenge
Sequence Division Challenge
Sequence Division Challenge
Given a sequence of integers, determine whether the sequence forms a single arithmetic progression with a common difference of ( k ). Formally, a sequence ( [a_1, a_2, \dots, a_n] ) is an arithmetic progression with common difference ( k ) if and only if for every ( 2 \leq i \leq n ), the equation ( a_i - a_{i-1} = k ) holds.
For example, the sequence ( [1, 3, 5, 7, 9, 11] ) is an arithmetic progression with ( k = 2 ), while ( [2, 5, 8, 10, 13] ) is not an arithmetic progression with ( k = 3 ).
inputFormat
The first line contains an integer ( T ), the number of test cases. Each test case consists of two lines:
- The first line contains two integers ( n ) and ( k ), where ( n ) is the number of elements in the sequence and ( k ) is the required common difference.
- The second line contains ( n ) space-separated integers representing the sequence.
outputFormat
For each test case, output a single line containing either ( YES ) if the sequence is an arithmetic progression with common difference ( k ), or ( NO ) if it is not.## sample
1
6 2
1 3 5 7 9 11
YES
</p>