#P6022. 快乐水

快乐水

Description

He arrives in front of a shop.

To attract customers to buy soda, the shop runs the following promotion: “Exchange 55 bottle caps for one bottle of soda.” So people come to the shop to buy soda.

After buying soda, he thinks of a question:

Suppose one bottle of soda comes with mm accessories. For the ii-th accessory, every aia_i of them can be exchanged for one brand-new bottle of soda. Now I have enough money to buy nn bottles of soda. What is the maximum number of sodas I can drink?

Input Format

The first line contains two integers n,mn,m, with the meanings described above.

The next line contains mm integers a1,a2,,ama_1,a_2,\cdots,a_m, with the meanings described above.

Output Format

If Little W can get soda for free infinitely, output one line containing the string Inf.

Otherwise, output one line containing an integer ss, which is the maximum number of sodas Little W can drink.

5 2
2 4

15
2 2
2 2

Inf

Hint

Explanation for Sample 1:

Step Drunk Undrunk Accessory 1 Accessory 2
1 0 5 0
2 5 0 5
3 3 1
4 8 0 4
5 3 0
6 11 0 3 3
7 1
8 12 0 2 4
9 2 0
10 14 0 2 2
11 1 0
12 15 0 1 3

Explanation for Sample 2:

Step Drunk Undrunk Accessory 1 Accessory 2
1 0 2 0
2 2 0 2
3 2 0
4 4 0 2
5 2 0
6 6 0 2
7 2 0
8 0 2
9 \vdots

It is obvious that Little W can keep getting soda for free infinitely like this.

Note: In this problem, we assume you cannot borrow/repay or buy on credit.

Constraints:

Test Point 1 is the same as Sample 2.

For 30%30\% of the testdata, n100n\le 100, m2m\le 2.

For 100%100\% of the testdata, 1n1041\le n\le 10^4, 1m51\le m\le 5, 1ai2×1031\le a_i\le 2\times10^3.

Translated by ChatGPT 5