아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Bruteforce

시간 제한5초메모리 제한512 MB

요약
질의마다 배열 원소 하나를 바꾸고, 정렬된 배열에 대해 floor(b_i * i^k / w)의 합을 998244353으로 나눈 나머지를 출력한다.
난이도

보통10점 중 4점

유형
완전 탐색, 정렬, 수학, 구현
정답자
아직 제출이 없습니다

문제

You are given fixed integers kk and ww.

For an array aa of length nn, let us define its weight in the following way:

  • Let bb be the array aa sorted in non-descending order.
  • The weight of aa is then defined as ∑_i=1n⌊b_i⋅ikw⌋\displaystyle \sum\_{i=1}^{n} \left\lfloor{\frac{b\_i \cdot i^k}{w}}\right\rfloor.

Here, ⌊x⌋\left\lfloor x \right\rfloor is the largest integer not exceeding xx.

For example, if k=2k = 2 and w=3w = 3, then the weight of a=\[3,2,2]a = \[3, 2, 2] is equal to:

 ⌊2⋅123⌋+⌊2⋅223⌋+⌊3⋅323⌋=0+2+9=11\displaystyle \left\lfloor {\frac{2 \cdot 1^2}{3}} \right\rfloor + \left\lfloor {\frac{2 \cdot 2^2}{3}} \right\rfloor + \left\lfloor {\frac{3 \cdot 3^2}{3}} \right\rfloor = 0 + 2 + 9 = 11.

You are given an initial array aa, and will be given qq queries. Each query changes one element of array aa. After each query, you should output the new weight of the array. Since array weights can be really large, you should output them modulo 998,244,353998\\,244\\,353.

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 nn, kk, ww (1≤n≤1051 \le n \le 10^5, 1≤k≤51 \le k \le 5, 1≤w≤51 \le w \le 5): the length of the array and the parameters from the statement.

The second line contains nn integers a_ia\_i (0≤a_i≤1050 \le a\_i \le 10^5): the elements of the original array.

The third line contains a single integer qq (1≤q≤1051 \le q \le 10^5): the number of queries.

Each of the next qq lines contains two integers, pos\mathit{pos} and xx (1≤pos≤n1 \le \mathit{pos} \le n, 0≤x≤1050 \le x \le 10^5). This describes a query that changes a_posa\_{\mathit{pos}} into xx.

출력

Output qq integers: the weights of the array after each change, modulo 998,244,353998\\,244\\,353.

예제2

  1. 예제 1

    입력
    3 1 1
    2 2 8
    2
    2 5
    3 6
    
    예상 출력
    36
    30
    
  2. 예제 2

    입력
    4 2 2
    1 3 3 7
    4
    1 1
    2 4
    3 8
    4 8
    
    예상 출력
    75
    80
    103
    108