CF538F.A Heap of Heaps

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn numbers a1a_{1} , ...... , ana_{n} . After that he asked Andrew for each kk from 1 to n1n-1 to build a kk -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 kk -ary heap is a rooted tree with vertices in elements of the array. If the elements of the array are indexed from 1 to nn , then the children of element vv are elements with indices k(v1)+2k(v-1)+2 , ...... , kv+1kv+1 (if some of these elements lie outside the borders of the array, the corresponding children are absent). In any kk -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)p(v) as the number of the parent of the element with the number vv . Let's say that for a non-root element vv the property of the heap is violated if a_{v}<a_{p(v)} .

Help Andrew cope with the task!

输入格式

The first line contains a single integer nn ( 2<=n<=21052<=n<=2·10^{5} ).

The second line contains nn space-separated integers a1a_{1} , ...... , ana_{n} ( 109<=ai<=109-10^{9}<=a_{i}<=10^{9} ).

输出格式

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

输入输出样例

  • 输入#1

    5
    1 5 4 3 2
    

    输出#1

    3 2 1 0
    
  • 输入#2

    6
    2 2 2 2 2 2
    

    输出#2

    0 0 0 0 0
    

说明/提示

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.

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

输入解题思路,AI测评打分。不知道怎么写?

首页