

実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
高橋君は電卓を持っています。電卓には最初 1 が表示されています。
高橋君は電卓に対して N 回操作を行います。
i 回目 (1\leq i\leq N) の操作では、その時点で画面に表示されている数に正の整数 A_i をかけます。
しかし、電卓には K 桁までしか表示できないため、計算結果が (K+1) 桁以上になる場合、代わりに 1 が画面に表示されます。
そうでない場合は正しく計算結果が表示されます。
N 回の操作の後に電卓に表示されている数を求めてください。
制約
- 1 \leq N \leq 100
- 1 \leq K \leq 18
- 1 \leq A_i < 10^K
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N K A_1 A_2 \ldots A_N
出力
N 回の操作の後に電卓に表示されている数を出力せよ。
入力例 1
5 2 7 13 3 2 5
出力例 1
10
今回電卓は 2 桁まで表示することができ、最初 1 が表示されています。これに対して、次のように高橋君は操作を行います。
- 1 回目の操作で、7 をかけます。1\times 7=7 であり、電卓には 7 が表示されます。
- 2 回目の操作で、13 をかけます。7\times 13=91 であり、電卓には 91 が表示されます。
- 3 回目の操作で、3 をかけます。91\times 3=273 であり、3 桁になってしまうため、電卓には 1 が表示されます。
- 4 回目の操作で、2 をかけます。1\times 2=2 であり、電卓には 2 が表示されます。
- 5 回目の操作で、5 をかけます。2\times 5=10 であり、電卓には 10 が表示されます。
入力例 2
2 1 2 5
出力例 2
1
Score : 200 points
Problem Statement
Takahashi has a calculator that initially displays 1.
He will perform N operations on the calculator.
In the i-th operation (1 \leq i \leq N), he multiplies the currently displayed number by a positive integer A_i.
However, the calculator can display at most K digits.
If the result of the multiplication has (K+1) 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
- 1 \leq N \leq 100
- 1 \leq K \leq 18
- 1 \leq A_i < 10^K
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N K A_1 A_2 \ldots A_N
Output
Output the number shown on the calculator after the N 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 \times 7 = 7, the calculator shows 7.
- The 2nd operation multiplies by 13. Since 7 \times 13 = 91, the calculator shows 91.
- The 3rd operation multiplies by 3. Since 91\times 3=273, which has three digits, the calculator shows 1.
- The 4th operation multiplies by 2. Since 1\times 2=2, the calculator shows 2.
- The 5th operation multiplies by 5. Since 2\times 5=10, the calculator shows 10.
Sample Input 2
2 1 2 5
Sample Output 2
1