Bruteforce
시간 제한5초메모리 제한512 MB
질의마다 배열 원소 하나를 바꾸고, 정렬된 배열에 대해 floor(b_i * i^k / w)의 합을 998244353으로 나눈 나머지를 출력한다.
문제
You are given fixed integers and .
For an array of length , let us define its weight in the following way:
- Let be the array sorted in non-descending order.
- The weight of is then defined as .
Here, is the largest integer not exceeding .
For example, if and , then the weight of is equal to:
.
You are given an initial array , and will be given queries. Each query changes one element of array . After each query, you should output the new weight of the array. Since array weights can be really large, you should output them modulo .
Note that the changes persist between queries. For example, the second query is applied to the array which is already changed by the first query.
입력
The first line contains three integers , , (, , ): the length of the array and the parameters from the statement.
The second line contains integers (): the elements of the original array.
The third line contains a single integer (): the number of queries.
Each of the next lines contains two integers, and (, ). This describes a query that changes into .
출력
Output integers: the weights of the array after each change, modulo .