Joy of Pokémon Observation
Time limit3sMemory limit2048 MB
For each habitat with total limb count t and up to three species with limb counts l_i, count the nonnegative integer solutions x_i of sum l_i x_i = t.
- Level
Medium6 of 10
- Topics
- Number theory, Math, Combinatorics
- Solved
- No attempts yet
Problem
The Pokémon Conservation Society protects Pokémon and their habitats all around the globe. In recent research, data about habitats was collected. Each habitat may be inhabited by several Pokémon species. Researchers know how many limbs each species has. Pokémon are swift and extremely good at hiding, so researchers were only able to detect the total number of limbs in each habitat. Researchers understand that it might not be possible to find the population of each species, but would like to understand how much uncertainty is left. How many different combinations of Pokémon would have the observed number of limbs?
Input
The first line contains a single integer (), the number of habitats. The next lines describe each habitat. Each line starts with two integers and (, ), where is the total number of limbs and is the number of species in the habitat. They are followed by integers (), the number of limbs for each species.
Output
Output the number of possible combinations of Pokémon in each habitat. Output lines, each containing a single integer.