Magic Formula |
You are given a quadratic function, f (n) = a x 2 + b x + c. You are also given a divisor d and a limit L. How many of the function values f (0), f (1),..., f (L) are divisible by d?
Input consists of a number of test cases. Each test case consists of a single line containing the numbers a b c d L ( -1000a, b, c1000, 1 < d < 1000000, 0L < 1000).
Input is terminated by a line containing `0 0 0 0 0' which should not be processed.
Print the answer for each test case (the number of function values f (0), f (1),..., f (L) divisible by d) on a separate line.
0 0 10 5 100 0 0 10 6 100 1 2 3 4 5 1 2 3 4 5 0 0 0 0 0
101 0 0 4