eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Candy`s Candy

Candy`s Candy

Candy has a stock of candy of \textbf{F} different flavors. She is going to make several packs of candy to sell them. Each pack must be either a \textit{flavored} pack, containing candy of a single flavor, or a \textit{variety} pack, containing candy of every flavor. Candy wants to make a nice packing with her candy. She decided that a nice packing must honor the following conditions: \begin{itemize} \item Each piece of candy must be placed in exactly one pack. \item Each pack, regardless of its type, must contain at least \textbf{2} pieces of candy. \item Each pack, regardless of its type, must contain the same number of pieces of candy. \item Within each variety pack, the number of pieces of candy of each avor must be the same. \item There must be at least one variety pack. \item There must be at least one flavored pack of each flavor. \end{itemize} Candy is wondering how many dierent nice packings of candy she could make. Two nice packings of candy are considered dierent if and only if they dier in the number of flavored packs, or in the number of variety packs, or in the number of pieces of candy per pack. Since Candy will sell her candy during the closing ceremony of this contest, you are urged to answer her question as soon as you can. \InputFile Each test case is described using two lines. The first line contains an integer \textbf{F} indicating the number of flavors (\textbf{2} ≤ \textbf{F}≤ \textbf{10^5}). The second line contains \textbf{F} integers \textbf{C_i}, indicating the number of pieces of candy of each flavor (\textbf{1} ≤ \textbf{C_i} ≤ \textbf{10^9} for \textbf{1} ≤ \textbf{i} ≤ \textbf{F}). The last test case is followed by a line containing one zero. \OutputFile For each test case output a line with an integer representing the number of dierent nice packings of candy, according to the rules given above.
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
3
15 33 21
2
1 1
2
2 2
2
3 3
3
1000000000 1000000000 1000000000
0
Выходные данные #1
4
0
0
1
832519396
Источник ACM ICPC Latin America 2011, November 4th-5th, 2011