z-lisnogcd
You are given a sequence of N integers. You have to find the longest non-decreasing subsequence such that for all pairs (a,b) of the numbers in the sequence gcd(a,b) = 1
InputFrom the first line of the standard input read one integer N (1 <= N <= 1000). From the next line read N integers that represent the sequence. Each element will be in the interval [1, 2000000000]
OutputTo the first line of the standard output write one integer M representing the length of the longest non-decreasing sequence with the property described above. To the next line write the M indices of the sequence you have found (separated by a space). The sequence is zero indexed, the first element has an index of 0. If there are multiple solutions with the same maximal length you can output any of them.
Input:
Output:
The elements in the sequence are 1, 2 and 3
5
1 2 2 4 3Output:
3
0 2 4The elements in the sequence are 1, 2 and 3
Input:
Output:
The elements in the sequence are 1, 2 and 3
5
1 2 2 4 3Output:
3
0 1 4The elements in the sequence are 1, 2 and 3
Input:
Output:
The elements in the sequence are 4 and 9
6
4 8 12 3 6 9Output:
2
0 5The elements in the sequence are 4 and 9
Input:
Output:
The elements in the sequence are 8 and 9
6
4 8 12 3 6 9Output:
2
1 5The elements in the sequence are 8 and 9
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.