P29086 [洛谷] Happy Water
普及
题目描述

Problem Background

Little W is going to buy Happy Water.

Problem Description

He arrives at a store.

To attract customers to buy Happy Water, the store has launched an activity: "5 bottle caps can be exchanged for one bottle of Happy Water." As a result, people flock to his store to buy Happy Water.

After buying Happy Water, he thinks of a question:

If a bottle of Happy Water comes with \( m \) accessories, for the \( i \)-th accessory, every \( a_i \) of them can be exchanged for a brand new bottle of Happy Water. Now, with the money to buy \( n \) bottles of Happy Water, how many bottles of Happy Water can he drink at most?

Input Format

The first line contains two integers \( n \) and \( m \), as described above.

The next line contains \( m \) integers \( a_1, a_2, \cdots, a_m \), as described above.

Output Format

If Little W can infinitely get Happy Water for free, output a single line containing the string Inf.

Otherwise, output a single line containing an integer \( s \), representing the maximum number of Happy Water bottles Little W can drink.

Sample Input and Output

Sample Input #1

5 2
2 4

Sample Output #1

15

Sample Input #2

2 2
2 2

Sample Output #2

Inf

Notes

Explanation of Sample #1:

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

Explanation of Sample #2:

Step Drank Not Drank Accessory 1 Accessory 2
1 0 2 0 0
2 2 0 2 2
3 2 2 0 0
4 4 0 2 2
5 4 2 0 0
6 6 0 2 2
7 6 2 0 0
8 8 0 2 2
9 $\vdots$ $\vdots$ $\vdots$ $\vdots$

Clearly, Little W can get Happy Water for free indefinitely.

Note: In this problem, we assume that borrowing/credit is not possible.

Data Range:

The first test point is the same as Sample #2.

For 30% of the data, \( n \leq 100 \), \( m \leq 2 \).

For 100% of the data, \( 1 \leq n \leq 10^4 \), \( 1 \leq m \leq 5 \), \( 1 \leq a_i \leq 2 \times 10^3 \).

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 2 2 4
样例输出
15