#P6022. 快乐水
快乐水
Description
He arrives in front of a shop.
To attract customers to buy soda, the shop runs the following promotion: “Exchange 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 accessories. For the -th accessory, every of them can be exchanged for one brand-new bottle of soda. Now I have enough money to buy bottles of soda. What is the maximum number of sodas I can drink?
Input Format
The first line contains two integers , with the meanings described above.
The next line contains integers , 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 , 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 | ||||
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 of the testdata, , .
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号