Generalized Arithmetic Progression Free Sequence
All submissions for this problem are available.
For given two positive integers a and b let's construct the sequence x, x, ... by the following rules. For k=1 we put x=1. Now let k >= 2. Then x[k] is the least positive integer such that the following two conditions hold
- x[k] > x[k - 1];
- for all i, j < k we have x[k] is not equal to a * x[i] - b * x[j].
You need to find the first n terms of this sequence.
Remark. Let a=2 and b=1. Then we see that sequence x, x, ... does not contain any arithmetic progression of length three as its subsequence. This justifies the problem title.
The first line contains a single integer T, the number of test cases. T test cases follow. The only line of each test case contains three integers a, b and n.
For each test case, output a single line containing the numbers x, x, ..., x[n] generated by the rules given in the problem statement and numbers a, b. Separate any two consecutive numbers in a line by a single space.
1 <= T <= 50
1 <= a, b <= 50
1 <= n <= 1000
Input: 3 2 1 10 1 1 5 4 2 4 Output: 1 2 4 5 10 11 13 14 28 29 1 2 3 4 5 1 3 4 5
|Tags||anton_lunyov, cook15, easy|
|Time Limit:||0.712667 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.