原题地址

题目描述

注意: 不易于人类理解题意,所以我就不翻译了

SaMer has written the greatest test case of all time for one of his problems. For a given array of integers, the problem asks to find the minimum number of groups the array can be divided into, such that the product of any pair of integers in the same group is a perfect square.

Each integer must be in exactly one group. However, integers in a group do not necessarily have to be contiguous in the array.

SaMer wishes to create more cases from the test case he already has. His test case has an array $A$ of $n$ integers, and he needs to find the number of contiguous subarrays of $A$ that have an answer to the problem equal to $k$ for each integer $k$ between $1$ and $n$ (inclusive).

Input

The first line of input contains a single integer $n$($1 leq n leq 5000$), the size of the array.

The second line contains $n$ integers $a_1$,$a_2$,$dots$,$a_n$ ($-10^8 leq a_i leq 10^8$), the values of the array.

Output

Output $n$ space-separated integers, the $k$-th integer should be the number of contiguous subarrays of $A$ that have an answer to the problem equal to $k$.

Examples
Input

Output

Idea

显然如果有一个数字包含完全平方数因数,抹掉这个因数对答案不会产生任何影响。根据这一点,我们可以直接除去所有数字的完全平方数因数,一个序列的答案就是这个序列里的数字种类。注意要特殊处理一下 0,因为他2可以被放置在任何一个序列中。

Code