LCC '21 Contest 5 J1 - Slippery Sequences

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

While reviewing for his upcoming math test, Josh has become stumped on a difficult problem and asks you for help.

In the problem, there is a sequence of integers whose first term is 0. Additionally, if the current term is x, the next term in the sequence will be equal to x^2+bx+c, where b and c are integers given by the problem. For example, if b = -2 and c = 3, the first three terms are 0, 3, and 6 respectively. Josh's task is to find the first five terms of this sequence.

Please help Josh solve this problem by printing out the first five terms.

Input Specifications

The first line of input will contain two space-separated integers, b and c (-10 \le b, c \le 10).

Output Specifications

Output five lines each containing one integer representing the first five terms of the sequence.

Note: It can be proven that all five terms will always fit in a 32-bit signed integer.

Sample Input

4 -2

Sample Output

0
-2
-6
10
138

Comments

There are no comments at the moment.