ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Переборные задачи > задача:


51082 - Sum is equal to K - 1

Гость
• Вопросы к жюри (1)

Задачи раздела

• 50708 - Binary Strings
• 50996 - Checkers - the shortest path
• 51067 - Jumping frog
• Post Office Delivery
• 50840 - Tanker trucks
• 51142 - Jump Min Value
• 50490 - Across the River
• 50828 - Arranging Time Table
• 51082 - Sum is equal to K - 1
• 50506 - The Biggest Island
• 50718 - Elevator
• 50472 - Minimum Sum Triangle
• 50593 - Transportimi
• 50711 - Snail Trails
• 50306 - Beautiful Numbers
• 50720 - Перестановки (2)
• 50707 - Rebus

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Sum is equal to K - 1

Math professor of your brother gave a homework for kids. The professor gives n numbers, and he asks if number k can be produced by adding or subtracting any given number.

Question: Write a program that is going to get information and decide if it's possible to calculate the given number k or not.

Input specification
In the first line, you will be given two integers: The number of numbers(n) and the number (k) to calculate where 0 ≤ n ≤ 17 and -20,000 ≤ k ≤ 20,000. Then, in the following line, you will be given n integers where each number is between -10,000 and 10,000.

Output specification:
Show "No", if it is not possible to calculate k. Otherwise, show "Yes". Note: Each input number can be used only once.

Sample Input I
4 7
1 2 3 5
Sample Input II
4 8
1 2 3 10
Sample Output I
Yes
Sample Output II
Yes

Explanation: For sample input 1: 5 + 2 = 7 or 5 + 3 - 1 = 7
For sample input 2: 10 - 2 = 8 or 10 - 3 + 1 = 8



Для отправки решений необходимо выполнить вход.

www.contester.ru