#ABC4062. Product Calculator
Product Calculator
Problem Statement
Takahashi has a calculator that initially displays 1. He will perform operations on the calculator. In the i-th operation , he multiplies the currently displayed number by a positive integer Ai . However, the calculator can display at most K digits. If the result of the multiplication has or more digits, the display shows 1 instead; otherwise, the result is shown correctly.
Find the number showing on the calculator after the N operations.
Constraints
All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Output the number shown on the calculator after the operations.
Sample Input 1
5 2
7 13 3 2 5
Sample Output 1
10
This calculator can display at most two digits and initially shows 1. Takahashi operates as follows:
The 1st operation multiplies by 7. Since 1×7=7, the calculator shows 7. The 2nd operation multiplies by 13. Since 7×13=91, the calculator shows 91. The 3rd operation multiplies by 3. Since 91×3=273, which has three digits, the calculator shows 1. The 4th operation multiplies by 2. Since 1×2=2, the calculator shows 2. The 5th operation multiplies by 5. Since 2×5=10, the calculator shows 10.
Sample Input 2
2 1
2 5
Sample Output 2
1