#GL0000151. Cặp chỉ số của đoạn tối ưu (Pair of Numbers)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Cặp chỉ số của đoạn tối ưu (Pair of Numbers)
Pair of Numbers
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Simon has a sequence of positive integers . An interval is valid if there exists an index inside the interval such that every in that interval is divisible by .
Among all valid intervals, maximize (one less than the interval length). If several intervals attain the maximum, output all their starting indices in increasing order.
Input
The first line contains . The second line contains the values .
Output
The first line contains the number of optimal intervals and the maximum . The second line contains all optimal starting indices in increasing order.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
5
4 6 9 3 6
Output
1 3
2
Explanation
The interval is valid because its element divides every entry. It has length , so . The entire length- array is invalid: its GCD is , which does not occur as an array element. Exactly one interval attains length .