#P7576. 「PMOI-3」期望乘积

    ID: 8230 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划 DP线段树O2优化动态规划优化矩阵加速矩阵乘法

「PMOI-3」期望乘积

Problem Description

ducati loves defining some strange things.

  • Two sequences are defined to be different if and only if their lengths are different, or they have the same length but there exists at least one position where the corresponding values are different.

  • The weight of a sequence AA is defined as the product of all numbers in AA.

  • The reachability between sequences is defined as follows:

    • Perform exactly tt operations. In each operation, choose a subarray of AA (note that the chosen subarray can be empty) and add 11 to every number in the subarray. If there exists an operation plan such that after all operations, AA becomes exactly the same as BB, then we say AA can reach BB.
  • The elegance value of sequence AA is defined as the sum of the weights of all different sequences that are reachable from AA.

Now, ducati has a sequence aa of length nn. He will query the elegance value of an interval many times.

Can you help this curious person? You only need to output each answer modulo 1000710007.

Input Format

The first line contains three integers n,q,tn,q,t, representing the length of the sequence, the number of queries, and the number of allowed modifications in each query.

The second line contains nn integers, representing the sequence aa.

The next qq lines each contain two positive integers l,rl,r, describing one query.

Output Format

For each query, output the answer modulo 1000710007.

2 1 1
1 2
1 2
15
10 3 3
1 5 3 2 2 4 6 3 2 3
1 7
4 9
3 10
3850
1166
3893

Hint

[Sample Explanation 1]

aa is {1,2}\{1,2\}. There is a total of 11 query.

All bb that aa can reach are as follows:

{1,3}{2,2}{2,3}{1,2}\{1,3 \} \{2,2 \} \{2,3 \}\{1,2 \}

The sum of their weights is 3+4+6+2=153+4+6+2=15.

[Sample Explanation 2]

For the second sample, I have a wonderful explanation, but unfortunately this space is too small, so I cannot write it down.

[Constraints]

This problem uses bundled testdata.

  • Subtask1 (10pts): n,q8n,q\le8;
  • Subtask2 (20pts): q=1q=1;
  • Subtask3 (30pts): n,q5×104n,q\le5\times10^4, t2t\le2;
  • Subtask4 (40pts): no special constraints.

For 100%100\% of the testdata, 1n,q1051\le n,q\le10^5, 1ai1041\le a_i\le10^4, 1t31\le t\le3, and for all queries, 1lrn1\le l\le r\le n.

Translated by ChatGPT 5