Codeforces Round #480 (Div. 2): D. Perfect Groups(思维题)

D. Perfect Groups
time limit per test 1 second
memory limit per test 256 megabytes
input standard input
output standard output

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≤n≤5000

), the size of the array.

The second line contains n
integers a1,a2,…,an (−108≤ai≤108

), 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

2
5 5

output

3 0

input

5
5 -4 2 1 8

output

5 5 3 2 0

input

1
0

output

1

题意:

已知有这么一道题:给你n个数字,你要将这n个数字打乱后分成k组,使得对于同一个组中的任意一对数字满足两个数相乘一定是个完全平方数,求出最小的k

而这道题的意思是:给你n个数字,这n个数字一共有(1+n)*n/2个连续子序列,对于连续每个子序列你都要求出上面的那个k,最后统计k=1的子序列有多少个,k=2的子序列有多少个……k=n的子序列有多少个

猜你喜欢

转载自blog.csdn.net/ffgcc/article/details/80260321