Jaher’s suitcase

[image]

Jaher is a brilliant algorithmist, but he is also a bit absent minded.
For example, he has some difficulties making things fit into his
suitcase. Can you help him?

For simplicity, let us assume a two-dimensional suitcase a × b, where
n rectangular objects must fit. Objects can be placed at any position
within the suitcase, without overlap, but they can not be rotated. In
how many ways can we put the objects?

Input

Input consists of several cases. Each case begins with a, b and n.
Follow n pairs of strictly positive natural numbers, which indicate the
sizes of the objects. The area of the objects exactly covers the
suitcase, and there is always at least one possible solution. (The first
case in the sample input corresponds to the picture.)

Output

[image]

For every suitcase, print a line with its number and how many possible
solutions exist.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:10:30.448Z

© Jutge.org, 2006–2026.
https://jutge.org
