#P8369. [POI 2000 R1] 条纹

[POI 2000 R1] 条纹

Problem Description

The Stripes game is a two-player game. The required items are a board and rectangular stripes in three colors: red, green, and blue. All red stripes have size c×1c \times 1, all green stripes have size z×1z \times 1, and all blue stripes have size n×1n \times 1, where c,z,nc, z, n are positive integers. Each player has an unlimited number of stripes of each color.

A board is a rectangle of size p×1p \times 1, consisting of pp cells of size 1×11 \times 1.

Players move alternately. In each move, a player chooses one rectangular stripe and places it on the board, following these rules:

  1. The stripe must not extend outside the board.
  2. It must not overlap any already placed stripe (not even partially).
  3. The edges of the stripe must coincide with the edges of the board cells.

Whoever cannot make a move loses.

The first player is the one who moves first in the game. Determine whether the first player has a winning strategy no matter how the second player plays.

Write a program that:

  1. Reads the stripe sizes and the sizes of at least one board.
  2. For each given board, determines whether the first player has a winning strategy.
  3. Outputs the results.

Input Format

The first line contains three integers c,z,nc, z, n, representing the lengths of the three stripes, in order: red, green, and blue. The numbers are separated by spaces.

The second line contains an integer mm, the number of different boards to consider. The following lines 33 to m+2m + 2 each contain one integer pp. Line i+2i + 2 gives the length of the ii-th board.

Output Format

Output mm lines. Exactly one number should be written on the ii-th line:

If the first player has a winning strategy for the ii-th board, output 11; otherwise output 22.

1 5 1
3
1
5
6
1
1
2

Hint

For 100%100\% of the data: 1c,z,n,m,p10001 \le c, z, n, m, p \le 1000.

Translated by ChatGPT 5