Ordered Problem Set
InterviewTime limit1sMemory limit2048 MB
Given n distinct difficulties in contest order, list each divisor k greater than 1 of n where every block of n/k consecutive problems is easier than the next block.
- Level
Easy2 of 10
- Topics
- Implementation, Brute force, Array
- Solved
- No attempts yet
Problem
You are running a programming contest with problems of distinct difficulties. You wish to announce ahead of time that the problems are ordered so that, when they are divided into sections numbered through , each with exactly problems, and problem is assigned to section , then for every pair of sections and with , every problem in section is easier than every problem in section . Note that must be greater than and be a factor of . However, the problems have already been sent to the printer, so the order cannot be changed. For what values of would this claim be true?
Input
The first line contains a single integer (), the number of problems. Each of the next lines contains a single integer (), the difficulty of a problem, listed in the order the problems appear in the set. The difficulties are distinct. Difficulty is the easiest and difficulty is the hardest.
Output
Output a list of integers, one per line, containing all valid values of in increasing order. If no valid value exists, output .