### 题目描述

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
2
5 5
###### Output
3 0

### Code

#include
#define maxn 50005
using namespace std;
void cut(int &x){
int flag=1;
if (x<0) flag=-1;
x=abs(x);
for (int i=2;(i*i)<=x;i++)
while (x%(i*i)==0)
x/=(i*i);
x*=flag;
}
int n,a[maxn],b[maxn],ans[maxn],vis[maxn],cnt;
map  mp;
int main(){
ios::sync_with_stdio(false);
cin>>n;
for (int i=1;i<=n;i++){
cin>>a[i];cut(a[i]);
if (!mp[a[i]]) mp[a[i]]=++cnt;
b[i]=mp[a[i]];
}
for (int i=1;i<=n;i++){
memset(vis,0,sizeof(vis));int tot=0;
for (int j=i;j<=n;j++){
if (!a[j]){
if (!tot) ans++;
else ans[tot]++;
}
else{
if (!vis[b[j]]) vis[b[j]]=1,tot++;
ans[tot]++;
}
}
}
for (int i=1;i<=n;i++)
cout<
 
 Share Show Comments 【CodeForces 980E】The Number Games / 题解 题目描述 Panel 国每年举办名为 Number Games的节目，全国每个区都将派出一名代表参赛。 该国有n个区，编号从1到n，每个区只有一条路径连接到其他区。每个区有一定数量的粉丝，来自$i$… 11 Jul 2018 【Luogu Wind Festival!】解题报告 比赛地址 试题列表 赛题 #A:P4741 [Wind Festival]Finding RhFe|满分: 100分 赛题… 10 Jul 2018 
 
 
 Topics Thought: 29 Selected: 27 Study: 26 Zepto's © 2021 Data & privacy Contact → Published with Ghost • Theme Attila • System theme 
 $(document).ready(function () { var viewport =$(window); var post = $('.post-content'); // Responsive videos with fitVids post.fitVids(); // Format code blocks and add line numbers function codestyling() {$('pre code').each(function(i, e) { // Code highlight hljs.highlightBlock(e); // No lines for plain text blocks if (!$(this).hasClass('language-text')) { var code =$(this); // Calculate amount of lines var lines = code.html().split(/\n(?!$)/g).length; var numbers = []; if (lines > 1) { lines++; } for (i = 1; i < lines; i++) { numbers += '<span class="line" aria-hidden="true">' + i + '</span>'; } code.parent().append('<div class="lines">' + numbers + '</div>'); } }); } codestyling(); // Reading progress bar on window top function readingProgress() { var postBottom = post.offset().top + post.height(); var viewportHeight = viewport.height(); var progress = 100 - (((postBottom - (viewport.scrollTop() + viewportHeight) + viewportHeight / 3) / (postBottom - viewportHeight + viewportHeight / 3)) * 100);$('.progress-bar').css('width', progress + '%'); (progress > 100) ? $('.progress-container').addClass('complete'):$('.progress-container').removeClass('complete'); } readingProgress(); // Trigger reading progress viewport.on({ 'scroll': function() { readingProgress(); }, 'resize': function() { readingProgress(); }, 'orientationchange': function() { readingProgress(); } }); // Check if disqus is defined by code injection if (typeof disqus === 'undefined') { // hide comment section $('.post-comments').css({ 'display': 'none' }); } else {$('#show-disqus').on('click', function() { $.ajax({ type: "GET", url: "//" + disqus + ".disqus.com/embed.js", dataType: "script", cache: true });$(this).parent().addClass('activated'); }); } });