 Print the Sequence
Medium Accuracy: 48.8% Submissions: 168 Points: 4

Construct the sequence arr, arr, ... by the following rules. For i=1 we put arr=1. Now let i >= 2. Then arr[i] is the least positive integer such that the following two conditions hold
(i) arr[i] > arr[i - 1];
(ii) for all k, j < i we have arr[i] is not equal to n1 * arr[k] - n2 * arr[j].
Find the first n terms of this sequence.

Example 1:

Input:
n1 = 2, n2 = 1, n = 10
Output:
1 2 4 5 10 11 13 14 28 29
Explanation:
The first 10 terms of the sequence is printed.

Example 2:

Input:
n1 = 1, n2 = 1, n = 5
Output:
1 2 3 4 5
Explanation:
The first 5 terms of the sequence is printed.

You don't need to read input or print anything. Your task is to complete the function findSeq() which takes 3 Integers n1, n2, and n as input and returns a vector denoting the first n terms of the sequence.

Expected Time Complexity: O(n2)
Expected Auxiliary Space: O(n2)

Constraints:
1<= n1,n2 <= 50

1 <= n <= 103

We are replacing the old Disqus forum with the new Discussions section given below.

### Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

#### My Submissions:  