#arc172a. A - Chocolate

A - Chocolate

问题陈述

Atcoder女士决定在情人节向 NN 位朋友分发巧克力。

对于第 ii 个朋友 (1iN)(1 \leq i \leq N) ,她想送一块大小为 2Ai×2Ai2^{A_i} \times 2^{A_i} 的方形巧克力棒。

她买了一块大小为 H×WH \times W 的长方形巧克力。

它由行划分为 HH 行和 WW 列的网格,每个单元格是一个 1×11 \times 1 正方形。确定是否可以沿着线将巧克力棒分成几块,以便为她的朋友获得所有的巧克力棒。

有剩菜就行了。

以上为机器翻译结果,仅供参考。

Problem Statement

Ms. AtCoder has decided to distribute chocolates to NN friends on Valentine's Day. For the ii-th friend (1iN)(1 \leq i \leq N), she wants to give a square chocolate bar of size 2Ai×2Ai2^{A_i} \times 2^{A_i}.

She has procured a rectangular chocolate bar of size H×WH \times W. It is partitioned by lines into a grid of HH rows and WW columns, each cell being a 1×11 \times 1 square.

Determine whether it is possible to divide the chocolate bar along the lines into several pieces to obtain all the chocolate bars for her friends. It is fine to have leftover pieces.

Constraints

  • 1H1091 \leq H \leq 10^9
  • 1W1091 \leq W \leq 10^9
  • 1N10001 \leq N \leq 1000
  • 0Ai25 (1iN)0 \leq A_i \leq 25 \ (1 \leq i \leq N)
  • All input values are integers.

Input

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

HH WW NN

A1A_1 A2A_2 \cdots ANA_N

Output

If the objective is achievable, print Yes; otherwise, print No.

Sample Input 1

4 4 4
1 0 0 1

Sample Output 1

Yes

By dividing a 4×44 \times 4 chocolate bar as shown in the figure below, you can obtain pieces of size 2×2,1×1,1×1,2×22 \times 2, 1 \times 1, 1 \times 1, 2 \times 2.

Sample Input 2

5 7 6
0 1 0 2 0 1

Sample Output 2

Yes

By dividing a 5×75 \times 7 chocolate bar as shown in the figure below, you can obtain pieces of size $1 \times 1, 2 \times 2, 1 \times 1, 4 \times 4, 1 \times 1, 2 \times 2$.

Sample Input 3

3 2 7
0 0 0 0 0 0 0

Sample Output 3

No

It is impossible to obtain seven pieces of size 1×11 \times 1 from a 3×23 \times 2 chocolate bar.

Sample Input 4

11 11 2
2 3

Sample Output 4

No

It is impossible to obtain both a 4×44 \times 4 and an 8×88 \times 8 piece from an 11×1111 \times 11 chocolate bar.

Sample Input 5

777 777 6
8 6 9 1 2 0

Sample Output 5

Yes
}