#P9129. 区间仿射区间和(大数组)(Range Affine Range Sum (Large Array))

区间仿射区间和(大数组)(Range Affine Range Sum (Large Array))

区间仿射区间和(大数组)(Range Affine Range Sum (Large Array))

问题描述

给定一个长度为 N N 的整数序列 a0,a1,,aN1 a_0, a_1, \dots, a_{N-1} ,初始时对所有 i i ,有 ai=0 a_i = 0
请按顺序处理以下 Q Q 个查询:

  • 0 l r b c:对每个 i=l,l+1,,r1 i = l, l+1, \dots, r-1 ,执行 aib×ai+c a_i \leftarrow b \times a_i + c
  • 1 l r:输出 i=lr1aimod998244353 \sum_{i=l}^{r-1} a_i \bmod 998244353

约束条件

  • 1N109 1 \leq N \leq 10^9
  • 1Q5×105 1 \leq Q \leq 5 \times 10^5
  • 0l<rN 0 \leq l < r \leq N
  • 1b<998244353 1 \leq b < 998244353
  • 0c<998244353 0 \leq c < 998244353

输入格式

N QN\ Q
Query0Query_0
Query1Query_1
:
QueryQ1Query_{Q-1}

1000000000 6
0 0 100 10 1
1 10 90
1 0 1000000000
0 50 10000 10 1
1 10 90
1 0 1000000000
80
100
480
10500