No.1538 The Shut-in Is Good at Subtraction.
問題文最終更新日: 2021-06-06 17:45:49
English (AI translation)
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.
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.
- First, choose and erase $7$ and $3$, and write $7-3$. At this point, $-2,5,4$ are written on the blackboard.
- 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.
- First, choose and erase $3$ and $1$, and write $3-1$. At this point, $5,7,2$ are written on the blackboard.
- Next, choose and erase $2$ and $5$, and write $2-5$. At this point, $7,-3$ are written on the blackboard.
- 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もしくは右上の雲マークをクリックしてアカウントを作成してください。
とりゐ
57tggx
logx
Re_menal2
pepper_aobuta