CF1380G.Circular Dungeon

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are creating a level for a video game. The level consists of nn rooms placed in a circle. The rooms are numbered 11 through nn . Each room contains exactly one exit: completing the jj -th room allows you to go the (j+1)(j+1) -th room (and completing the nn -th room allows you to go the 11 -st room).

You are given the description of the multiset of nn chests: the ii -th chest has treasure value cic_i .

Each chest can be of one of two types:

  • regular chest — when a player enters a room with this chest, he grabs the treasure and proceeds to the next room;
  • mimic chest — when a player enters a room with this chest, the chest eats him alive, and he loses.

The player starts in a random room with each room having an equal probability of being chosen. The players earnings is equal to the total value of treasure chests he'd collected before he lost.

You are allowed to choose the order the chests go into the rooms. For each kk from 11 to nn place the chests into the rooms in such a way that:

  • each room contains exactly one chest;
  • exactly kk chests are mimics;
  • the expected value of players earnings is minimum possible.

Please note that for each kk the placement is chosen independently.

It can be shown that it is in the form of PQ\frac{P}{Q} where PP and QQ are non-negative integers and Q0Q \ne 0 . Report the values of PQ1(mod998244353)P \cdot Q^{-1} \pmod {998244353} .

输入格式

The first contains a single integer nn ( 2n31052 \le n \le 3 \cdot 10^5 ) — the number of rooms and the number of chests.

The second line contains nn integers c1,c2,,cnc_1, c_2, \dots, c_n ( 1ci1061 \le c_i \le 10^6 ) — the treasure values of each chest.

输出格式

Print nn integers — the kk -th value should be equal to the minimum possible expected value of players earnings if the chests are placed into the rooms in some order and exactly kk of the chests are mimics.

It can be shown that it is in the form of PQ\frac{P}{Q} where PP and QQ are non-negative integers and Q0Q \ne 0 . Report the values of PQ1(mod998244353)P \cdot Q^{-1} \pmod {998244353} .

输入输出样例

  • 输入#1

    2
    1 2

    输出#1

    499122177 0
  • 输入#2

    8
    10 4 3 6 5 10 7 5

    输出#2

    499122193 249561095 249561092 873463811 499122178 124780545 623902721 0

说明/提示

In the first example the exact values of minimum expected values are: 12\frac 1 2 , 02\frac 0 2 .

In the second example the exact values of minimum expected values are: 1328\frac{132} 8 , 548\frac{54} 8 , 308\frac{30} 8 , 178\frac{17} 8 , 128\frac{12} 8 , 78\frac 7 8 , 38\frac 3 8 , 08\frac 0 8 .

首页