If an=n^2, and d=3 then the first terms of bm are:
1, 1, 1, 4, 4, 4, 4, 4, 4, 9, 9, 9, 9, 9, 9, 9, 9 , 9, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 25, 25, ...
For k=1 you have to print 1.
For k=2 you have to print 1.
For k=3 you have to print 1.
For k=4 you have to print 4.
For k=9 you have to print 4.
For k=10 you have to print 9.
For k=23 you have to give 16.
I'll attempt to explain the problem clearer as the given explanation was very confusing and it took me a long time to understand.
If d = 1 then the sequence is
1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, .....
with each successive integer having one additional term.
Similarly if d = 2 then the sequence is
1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, .....
Given the original sequence the number of terms for each integer is multiplied by d. To find the kth term of this sequence simply count to that many terms. For example k = 5 results in 2 in the above sequence, as the 5th term is a 2.
Now for that part that I found to be explained poorly. The first line of each case describes a polynomial that you substitute the kth term into. However the first number in this line is not part of the polynomial, instead it describes the highest power in the polynomial.
For example, in the sample input line '4 3 0 0 0 23', the 4 means that the polynomial goes up to x^4. The following numbers then describe the polynomial in increasing powers.
In the given example, the polynomial is:
3(x^0) + 0(x^1) + 0(x^2) + 0(x^3) + 23(x^4)
The x value represents the previously found kth term. So if the kth term was found to be 3, as it is in the first sample input, you would evaluate the polynomial to
3(3^0) + 0(3^1) + 0(3^2) + 0(3^3) + 23(3^4) = 1866, the correct sample output.