当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。
Given two integral m × n matrices A = {aij} and B = {bij}, we define a sequence of matrices SB = {Bk} with B1 = B where, for each k > 1,
__poj_jax_start__b_{ij}^k=\sum_{p=1}^{i-1}a_{pj}b_{pj}^k+\sum_{q=1}^{j-1}a_{iq}b_{iq}^k+b_{ij}^{k-1}__poj_jax_end__.
Write a program that is capable of evaluating SB efficiently.
The input consists of a single test case and is given in the following format:
m | n | t | |
a11 | a12 | ⋯ | a1n |
a21 | a22 | ⋯ | a2n |
⋮ | ⋮ | ⋱ | ⋮ |
am1 | am2 | ⋯ | amn |
b11 | b12 | ⋯ | b1n |
b21 | b22 | ⋯ | b2n |
⋮ | ⋮ | ⋱ | ⋮ |
bm1 | bm2 | ⋯ | bmn |
i1 | j1 | k1 | |
i2 | j2 | k2 | |
⋮ | ⋮ | ⋮ | |
it | jt | kt |
Bounds on the values are: 1 ≤ m, n ≤ 20; 1 ≤ t ≤ 1000; 0 ≤ aij, bij ≤ 10; 1 ≤ it ≤ m; 1 ≤ jt ≤ n; 1 ≤ kt ≤ 109.
For each t, output bitjtkt mod 1,000,000,007.
2 2 5 1 2 2 1 1 1 1 1 1 1 2 1 2 2 2 1 2 2 2 2 1 1 3
1 2 2 9 1
1,000,000,007 is a prime.
时间上限 | 内存上限 |
1000 | 131072 |