#P8646. Bun Steamer Combination Problem
Bun Steamer Combination Problem
Bun Steamer Combination Problem
In a local bun shop, there are N types of steamer baskets. The i-th basket can hold exactly $A_i$ buns, and there are infinitely many baskets available for each type. When a customer wants to buy X buns, the seller will quickly choose some baskets so that the total number of buns equals X. However, sometimes it is impossible to exactly obtain X buns using any combination of baskets.
For example, if there are 3 types of baskets with capacities $3$, $4$, and $5$, then when a customer orders $11$ buns, the seller can pick two baskets of capacity $3$ and one basket of capacity $5$ (alternatively, one basket of $3$ and two baskets of $4$ will also work). On the other hand, if the capacities are $4$, $5$, and $6$, then it is impossible to form $7$ buns from any combination.
Your task is to determine how many positive integers X cannot be represented as a nonnegative integer combination of $A_1, A_2,\dots, A_N$. If there are infinitely many such numbers, output infinite
.
Note: By a classical result, if \( \gcd(A_1, A_2, \dots, A_N) \neq 1 \), then only multiples of \( \gcd(A_1, A_2, \dots, A_N) \) can be formed, and hence there are infinitely many unreachable numbers.
inputFormat
The input consists of two lines. The first line contains a single integer N representing the number of basket types. The second line contains N space-separated integers $A_1, A_2, \dots, A_N$, where $A_i$ is the capacity of the i-th basket.
N A1 A2 ... AN
outputFormat
If there are infinitely many positive integers that cannot be formed, output infinite
. Otherwise, output a single integer representing the number of positive integers that cannot be represented as a sum of the given basket capacities.
sample
2
3 5
4