NEERC, Central subregion, Rybinsk, October 2002E. ArrayTime limit: 1.0 second Memory limit: 64 MB
Imperative programming languages allow the use of both linear and multidimensional arrays. E.g. in Pascal for an array named X the expression array[0..2, 0..1, 0..3] declares a threedimensional array having the following boundaries for each dimension: 0..2, 0..1, 0..3. (We consider only zerobased arrays here though other values are possible in Pascal for lower bounds of each dimension.) It is always possible to determine the order in which the items of the array are enumerated. Consider that this order is determined by the principle "righthand indices change faster". This means that the last (rightmost) index iterates through all possible values, then the index that is next to it (second from the right) changes its value by 1, and the last index iterates between the lower and upper boundaries again, and so on. Example. The items of the array mentioned above are enumerated in the following order: X[0,0,0], X[0,0,1], X[0,0,2], X[0,0,3], X[0,1,0], X[0,1,1], X[0,1,2], X[0,1,3], X[1,0,0], X[1,0,1], X[1,0,2], X[1,0,3], X[1,1,0], X[1,1,1], X[1,1,2], X[1,1,3], X[2,0,0], X[2,0,1], X[2,0,2], X[2,0,3], X[2,1,0], X[2,1,1], X[2,1,2], X[2,1,3]. Let an nary array X is declared as array[0..k_{1}, 0..k_{2}, …, 0..k_{n}]. The theory says that the order P of any item X[i_{1}, i_{2}, …, i_{n}] is calculated as P(i_{1}, i_{2}, …, i_{n}) = 1 + D_{1}*i_{1}+D_{2}*i_{2}+… D_{n}*i_{n}, if we use the enumeration described above. Here D_{1}, D_{2}, …, D_{n} are socalled index multipliers. Example. For the array in discussion the index multipliers are D_{1} = 8, D_{2} = 4, D_{3} = 1. Then, for example, the order of X[1,0,3] will be P(1,0,3) = 1+8*1+4*0+1*3 = 12. Your task is to calculate the unknown upper boundaries (k_{1}, k_{2}, …, k_{n}) for given index multipliers D_{1}, D_{2}, …, D_{n} and total number of items s in the array. InputThe first line of the input contains n — the number of dimensions (1 ≤ n ≤ 20) and s — the total number of items in the array (1 ≤ s < 2^{31}−1). The following n lines contain the index multipliers D_{1}, D_{2}, …, D_{n}. OutputDetermine the upper boundaries for each dimension of the array in order: k_{1}, k_{2}, …, k_{n} (0 < k_{i} ≤ 1000). The numbers in the output may be delimited with spaces and/or line breaks. Sampleinput  output 

3 24
8
4
1
 2 1 3

Problem Source: 20022003 ACM Central Region of Russia Quarterfinal Programming Contest, Rybinsk, October 2002
To submit the solution for this problem go to the Problem set: 1228. Array 
