Programming contests

ICPC programozó csapatverseny, házi forduló, 2019. október 30.

October 30, 2019 10:00 AM – October 30, 2019 3:00 PM

Frame

Let's consider a rectangle of size X × Y with the middle rectangle of size (X – 2) × (Y – 2) cut out. We will call this figure a frame of size X × Y. Figure 1 shows the frame of size 5 × 6.


Figure 1. A frame of size 5 × 6

Figure 2. A frame of size 5 × 6,
paved with tiles of size 3 × 1

Let's assume that we have unlimited number of tiles of size A × 1. Consider the following problem: is it possible to completely pave a frame of size X × Y using these tiles (tiles can be rotated by 90 degrees)? For example, a frame of size 5 × 6 in Figure 1 can be paved completely with tiles of size 3 × 1 (one way to do so is shown in Figure 2), but can't be paved with tiles of size 4 × 1.

Input Specification

The first input line contains two integers X and Y (3 ≤ X ≤ 106, 3 ≤ Y ≤ 106). The second line contains an integer N, the number of tile types to be analyzed (1 ≤ N ≤ 1000). Each of the following N lines contains one integer, not exceeding 106. Let's denote the integer on the (K + 2)-th line of the input with AK.

Output Specification

Output N lines, where the Kth line should contain the word “YES“ if it is possible to tile the frame of size X × Y with tiles of size AK × 1, and the word “NO“ otherwise.

Sample Input

  1. 5 6
  2. 2
  3. 3
  4. 4
download as text file

Output for Sample Input

  1. YES
  2. NO
download as text file

Original Problem

Southeastern Europe Regional Contest, 2014

University of Debrecen; Faculty of Informatics; v. 03/01/2019