COCI '18 Contest 6 #5 Mobitel

View as PDF

Submit solution

Points: 20 (partial)
Time limit: 6.0s
Memory limit: 64M

Problem type

Little Nikola has recently learned a multiplication table. To try to continue learning, he came up with the following task.

He made a table of size R \times S. In each field of the table he wrote an integer value and asked himself: How many possible ways are there to get from the upper left corner to the lower right corner of the table by moving each step to one field right or down, so that a product of all the numbers on the path (including the initial and the final field) is at least N?

Since currently he has no time, he has asked you for help. Since the required number of ways can be quite large, just print its remainder of division by 10^9 + 7.

Input

In the first line there are integer numbers R, S (1 \le R, S \le 300) and N (1 \le N \le 10^6).

In the next R lines there are S integer numbers between 1 and 10^6 which denotes the numbers written in each field of the table.

Output

In the only line print the remainder of the required number of the ways modulo 10^9 + 7.

Scoring

In the test samples totally worth 20% of the points it will hold N \le 300.

In the test samples totally worth 20% of the points it will hold R, S \le 100, and all the numbers in the table will be less than or equal to 10.

In the test samples totally worth additional 30% it will hold R, S \le 100.

Sample Input 1

2 3 200
2 3 4
5 6 7

Sample Output 1

2

Explanation for Sample Output 1

There are three possible ways:

  • 2 \to 3 \to 4 \to 7 - total product 168
  • 2 \to 3 \to 6 \to 7 - total product 252
  • 2 \to 5 \to 6 \to 7 - total product 420

Sample Input 2

3 3 90
2 1 1
45 1 1
1 1 1

Sample Output 2

3

Sample Input 3

2 5 3000
1 2 3 4 5
6 7 8 9 10

Sample Output 3

3

Comments

There are no comments at the moment.