#P5307. [COCI 2018/2019 #6] Mobitel

    ID: 4256 远端评测题 6000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划,dp2019块状链表,块状数组,分块COCI

[COCI 2018/2019 #6] Mobitel

Description

He drew a matrix with rr rows and ss columns, and each cell contains a positive integer.
He wants to know: if you walk from the top-left corner to the bottom-right corner, and each step can only go right or down to an adjacent cell, how many paths have the product of all numbers on the path not less than nn?

Since the answer may be very large, output the result modulo 109+710^9 + 7.

Input Format

The first line contains three positive integers r,s,nr, s, n.
Next come rr lines, each containing ss positive integers, representing the numbers in each row of the matrix in order.

Output Format

Output one line with one integer representing the answer.

2 3 200
2 3 4
5 6 7
2
3 3 90
2 1 1
45 1 1
1 1 1
3

Hint

Sample 11 Explanation:

There are 33 paths in total, among which 22 satisfy the condition:
23672 \rightarrow 3 \rightarrow 6 \rightarrow 7, with product 252252.
25672 \rightarrow 5 \rightarrow 6 \rightarrow 7, with product 420420.

Constraints:

For 20%20\% of the testdata:
The numbers in the matrix do not exceed 1010.
For 50%50\% of the testdata:
1r,s1001 \le r, s \le 100.
For 100%100\% of the testdata:
1r,s3001 \le r, s \le 300.
1n1061 \le n \le 10^6.
The numbers in the matrix do not exceed 10610^6.

Translated by ChatGPT 5