P27047 [AtCoder] Welcome Newbie Sequence - Easy
提高-
题目描述

Problem Description

Score: $ 300 $ points

PAKEN, a new member, received an integer sequence of length $ N $, denoted as $A = \{ A_1, A_2, A_3, ..., A_N \}$, from a senior as a welcoming gift.

PAKEN arranged $ N $ cards in a row on his desk, with the number $ A_i $ written on the $ i $-th card from the left.

You can perform the following operation on this sequence of cards as many times as you like:

  • Select two adjacent cards, remove them, and then place a new card in the removed position with the product of the two removed cards written on it.
  • For example, if the sequence of cards is { 7, 6, 8, 4 } and you remove the cards 6 and 8, the new sequence will be { 7, 48, 4 }.

PAKEN loves the integer $ P $ very much. He will be delighted if there is at least one card on the desk with the number $ P $ written on it. Determine whether it is possible to make PAKEN happy.

Input Format

The input is given from the standard input in the following format:

$ N $ $ P $ $ A_1 $ $ A_2 $ $ A_3 $ ... $ A_N $

Output Format

If it is possible to make PAKEN happy, output Yay!, otherwise output :(.

Sample Input and Output

Sample Input #1

5 10
1 3 5 2 4

Sample Output #1

Yay!

Sample Input #2

None

Sample Output #2

:(

Sample Input #3

None

Sample Output #3

Yay!

Notes/Hints

Constraints

  • $ N $ is an integer between $ 1 $ and $ 100,000 $ inclusive.
  • $ P $ is an integer between $ 1 $ and $ 1,000,000,000 $ inclusive.
  • $ A_i $ is an integer between $ 1 $ and $ 9 $ inclusive.

Subtasks

There are no subtasks or partial points for this problem.

Sample Explanation 1

The initial sequence of cards is { 1, 3, 5, 2, 4 }. By performing the operation on cards 5 and 2, the sequence becomes { 1, 3, 10, 4 }. Since 10 appears, PAKEN will be happy.

Sample Explanation 2

The initial sequence of cards is { 3, 4 }. Since there is no card with $ P = 11 $ initially, the only possible operation is to remove cards 3 and 4. After the operation, the sequence becomes { 12 }, which cannot produce 11. Therefore, it is not possible to make PAKEN happy.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 10 1 3 5 2 4
样例输出
Yay!