CF1218E.Product Tuples

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

While roaming the mystic areas of Stonefalls, in order to drop legendary loot, an adventurer was given a quest as follows. He was given an array A=a1,a2,...,aNA = {a_1,a_2,...,a_N } of length NN , and a number KK .

Define array BB as $B(q, A) = $ { qa1,qa2,...,qaNq-a_1, q-a_2, ..., q-a_N }. Define function FF as F(B,K)F(B,K) being sum of products of all KK -tuples of elements in array BB . For example, if the array BB is [2,3,4,5][2,3,4,5] , and with K=3K=3 , sum of products of all 3-tuples is $$$$F(B, 3) = 234+235+345+245 $$

He was then given a number Q, number of queries of two types:

  • Type 1: Given qq , ii , and dd calculate F(B(q,A),K)F(B(q, A), K) where we make change to initial array as A\[i\] = d .
  • Type 2: Given qq , LL , RR , and dd calculate F(B(q,A),K)F(B(q, A), K) where we make change to initial array as A\[i\] = A\[i\] + d for all ii in range \[L, R\]$$ inclusive.

    All changes are temporarily made to initial array, and don't propagate to following queries. Help the adventurer calculate the answer to a quest, and finally get that loot!

输入格式

In the first two lines, numbers NN ( 1N21041 \leq N \leq 2*10^4 ) and KK ( 1KN1 \leq K \leq N ), the length of initial array AA , and tuple size, followed by a1,a2,a3,,aNa_1,a_2,a_3,…,a_N ( 0ai1090 \leq a_i \leq 10^9 ) , elements of array AA , in the next line. Then follows number QQ ( Q10Q \leq 10 ), number of queries. In the next QQ lines come queries of the form:

  • 1 q i d, for type 1,
  • 2 q L R d, for type 2,

as explained above ( 0q,d109,1i,L,RN0 \leq q, d \leq 10^9, 1 \leq i,L,R \leq N )

输出格式

Print QQ lines, the answers to queries, modulo 998244353998244353 .

输入输出样例

  • 输入#1

    5
    2
    1 2 3 4 5
    3
    1 6 1 1
    1 6 5 2
    2 6 2 3 1
    

    输出#1

    85
    127
    63
    

说明/提示

In the first query array A = [1, 2, 3, 4, 5], B = [5, 4, 3, 2, 1], sum of products of 2-tuples = 85.

In second query array A = [1, 2, 3, 4, 2], B = [5, 4, 3, 2, 4], sum of products of 2-tuples = 127

In third query array A = [1, 3, 4, 4, 5], B = [5, 3, 2, 2, 1], sum of products of 2-tuples = 63

首页