#C11479. Verify Maria's Arithmetic Progression

    ID: 40799 Type: Default 1000ms 256MiB

Verify Maria's Arithmetic Progression

Verify Maria's Arithmetic Progression

In this problem, you are given several test cases. In each test case, you are provided with three integers ( n ), ( a ), and ( d ), where ( n ) is the number of terms, ( a ) is the first term and ( d ) is the common difference of an arithmetic progression. You are also given Maria's attempted sequence of ( n ) integers. Your task is to verify whether Maria's sequence exactly matches the expected arithmetic progression. The expected ( j^{th} ) term ( T_j ) is computed by the formula: [ T_j = a + j \cdot d \quad \text{for} \quad j = 0, 1, \ldots, n-1. ] For each test case, output "YES" if the sequence is correct, and "NO" otherwise.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains an integer t representing the number of test cases.
  • For each test case, the first line contains three space-separated integers: n (the number of terms), a (the first term), and d (the common difference).
  • The next line contains n space-separated integers representing Maria's attempted sequence.

outputFormat

For each test case, print a single line to stdout containing "YES" if the sequence matches the required arithmetic progression, or "NO" otherwise.## sample

1
5 1 2
1 3 5 7 9
YES

</p>