Codeforces Round 300
F
A Heap of Heaps
Codeforces
2200
原题
← EG →
翻译中…

Andrew skipped lessons on the subject 'Algorithms and Data Structures' for the entire term. When he came to the final test, the teacher decided to give him a difficult task as a punishment.

翻译中…

The teacher gave Andrew an array of $*n*$ numbers $*a*_{1}$, $...$, $*a*_{*n*}$. After that he asked Andrew for each $*k*$ from 1 to $*n* - 1$ to build a $*k*$-ary heap on the array and count the number of elements for which the property of the minimum-rooted heap is violated, i.e. the value of an element is less than the value of its parent.

翻译中…

Andrew looked up on the Wikipedia that a $*k*$-ary heap is a rooted tree with vertices in elements of the array. If the elements of the array are indexed from 1 to $*n*$, then the children of element $*v*$ are elements with indices $*k*(*v* - 1) + 2$, $...$, $*kv* + 1$ (if some of these elements lie outside the borders of the array, the corresponding children are absent). In any $*k*$-ary heap every element except for the first one has exactly one parent; for the element 1 the parent is absent (this element is the root of the heap). Denote $*p*(*v*)$ as the number of the parent of the element with the number $*v*$. Let's say that for a non-root element $*v*$ the property of the heap is violated if $*a*_{*v*} < *a*_{*p*(*v*)}$.

翻译中…

Help Andrew cope with the task!

翻译中…

Input

翻译中…

The first line contains a single integer $*n*$ ($2 ≤ *n* ≤ 2·10^{5}$).

翻译中…

The second line contains $*n*$ space-separated integers $*a*_{1}$, $...$, $*a*_{*n*}$ ($- 10^{9} ≤ *a*_{*i*} ≤ 10^{9}$).

翻译中…

Output

翻译中…

in a single line print $*n* - 1$ integers, separate the consecutive numbers with a single space — the number of elements for which the property of the $*k*$-ary heap is violated, for $*k* = 1$, $2$, $...$, $*n* - 1$.

翻译中…

Note

翻译中…

Pictures with the heaps for the first sample are given below; elements for which the property of the heap is violated are marked with red.

翻译中…

image image image image

翻译中…

In the second sample all elements are equal, so the property holds for all pairs.

翻译中…

样例

Input #1
5
1 5 4 3 2
Output #1
3 2 1 0
InputCopy OutputCopy
Input #2
6
2 2 2 2 2 2
Output #2
0 0 0 0 0
InputCopy OutputCopy
题目信息
题号
538F
时间限制
3 s
内存限制
512 MB
标签
暴力
数据结构
数学
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。