問題一覧 > 通常問題

No.1538 The Shut-in Is Good at Subtraction.

レベル : / AI推定難易度 : 1800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 39
作問者 : とりゐ / テスター : 57tggx logx 👑 qand Re_menal2 ゅゅ pepper_aobuta
お気に入りにしたユーザー ProblemId : 6529 / 自分の提出
問題文最終更新日: 2021-06-06 17:45:49
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
ゅゅちゃんお誕生日コンテスト (順位表) の他の問題:

Problem Statement

There are $N$ integers $A_1,A_2,\ldots, A_N$ written on a blackboard. Yuyu-chan, who is good at subtraction, can repeat the following operation any number of times between $0$ and $N-1$, inclusive.

  • Choose $2$ numbers written on the blackboard and erase them. Letting the erased numbers be $x,y$, write either $x-y$ or $y-x$ on the blackboard.
Determine whether these operations can bring the blackboard to a state in which the numbers written on it include $K$.

Input

$N\ K$
$A_1\ A_2\ \ldots\ A_N$ 

  • All inputs are integers.
  • $2\leq N\leq 20$
  • $-10^9\leq K\leq 10^9$
  • $-10^9\leq A_i\leq10^9\ (1\leq i\leq N)$

Output

Print Yes if it is possible to reach a state that includes $K$, and No otherwise.

Sample

Sample 1
Input
4 6
7 -2 5 3
Output
Yes

The following operations leave $6$ on the blackboard.

  1. First, choose and erase $7$ and $3$, and write $7-3$. At this point, $-2,5,4$ are written on the blackboard.
  2. Next, choose and erase $4$ and $-2$, and write $4-(-2)$. At this point, $5,6$ are written on the blackboard.

Sample 2
Input
4 10
1 3 5 7
Output
Yes

The following operations leave $10$ on the blackboard.

  1. First, choose and erase $3$ and $1$, and write $3-1$. At this point, $5,7,2$ are written on the blackboard.
  2. Next, choose and erase $2$ and $5$, and write $2-5$. At this point, $7,-3$ are written on the blackboard.
  3. Finally, choose and erase $7$ and $-3$, and write $7-(-3)$. At this point, $10$ is written on the blackboard.

Sample 3
Input
3 6
4 -12 16
Output
No

No matter how the operations are performed, $6$ cannot be left on the blackboard.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。