#abc296c. C - Gap Existence

C - Gap Existence

Score : 300300 points

问题描述

给定一个包含 NN 个数的序列:A=(A1,,AN)A=(A_1,\ldots,A_N)

确定是否存在一对 (i,j)(i,j),满足 1i,jN1\leq i,j \leq N,使得 AiAj=XA_i-A_j=X

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given a sequence of NN numbers: A=(A1,,AN)A=(A_1,\ldots,A_N).

Determine whether there is a pair (i,j)(i,j) with 1i,jN1\leq i,j \leq N such that AiAj=XA_i-A_j=X.

Constraints

  • 2N2×1052 \leq N \leq 2\times 10^5
  • 109Ai109-10^9 \leq A_i \leq 10^9
  • 109X109-10^9 \leq X \leq 10^9
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN XX

A1A_1 \ldots ANA_N

Output

Print Yes if there is a pair (i,j)(i,j) with 1i,jN1\leq i,j \leq N such that AiAj=XA_i-A_j=X, and No otherwise.

Sample Input 1

6 5
3 1 4 1 5 9

Sample Output 1

Yes

We have A6A3=94=5A_6-A_3=9-4=5.

Sample Input 2

6 -4
-2 -7 -1 -8 -2 -8

Sample Output 2

No

There is no pair (i,j)(i,j) such that AiAj=4A_i-A_j=-4.

Sample Input 3

2 0
141421356 17320508

Sample Output 3

Yes

We have A1A1=0A_1-A_1=0.

update @ 2024/3/10 12:18:02