Description
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 300300 points
Problem Statement
We have a sequence of NN positive integers: A=(A_1,\dots,A_N)A=(A1,…,AN).
Let BB be the concatenation of 10^{100}10100 copies of AA.
Consider summing up the terms of BB from left to right. When does the sum exceed XX for the first time?
In other words, find the minimum integer kk such that:
\displaystyle{\sum_{i=1}^{k} B_i \gt X}i=1∑kBi>X.
Constraints
-
1 \leq N \leq 10^51≤N≤105
-
1 \leq A_i \leq 10^91≤Ai≤109
-
1 \leq X \leq 10^{18}1≤X≤1018
-
All values in input are integers.
Input
Input is given from Standard Input in the following format:
NNA_1A1\ldots…A_NANXX
Output
Print the answer.
HINT
We have B=(3,5,2,3,5,2,3,5,2,\dots)B=(3,5,2,3,5,2,3,5,2,…).
\displaystyle{\sum_{i=1}^{8} B_i = 28 \gt 26}i=1∑8Bi=28>26 holds, but the condition is not satisfied when kk is 77 or less, so the answer is 88.