CF1380G.Circular Dungeon
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are creating a level for a video game. The level consists of n rooms placed in a circle. The rooms are numbered 1 through n . Each room contains exactly one exit: completing the j -th room allows you to go the (j+1) -th room (and completing the n -th room allows you to go the 1 -st room).
You are given the description of the multiset of n chests: the i -th chest has treasure value ci .
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 k from 1 to n place the chests into the rooms in such a way that:
- each room contains exactly one chest;
- exactly k chests are mimics;
- the expected value of players earnings is minimum possible.
Please note that for each k the placement is chosen independently.
It can be shown that it is in the form of QP where P and Q are non-negative integers and Q=0 . Report the values of P⋅Q−1(mod998244353) .
输入格式
The first contains a single integer n ( 2≤n≤3⋅105 ) — the number of rooms and the number of chests.
The second line contains n integers c1,c2,…,cn ( 1≤ci≤106 ) — the treasure values of each chest.
输出格式
Print n integers — the k -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 k of the chests are mimics.
It can be shown that it is in the form of QP where P and Q are non-negative integers and Q=0 . Report the values of P⋅Q−1(mod998244353) .
输入输出样例
输入#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: 21 , 20 .
In the second example the exact values of minimum expected values are: 8132 , 854 , 830 , 817 , 812 , 87 , 83 , 80 .