![]() |
||||||||||
|
||||||||||
Here’s a Product Which Will Make You TensorTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 397 Accepted Submission(s): 98 Problem Description Most people are familiar with how to multiply two matrices together. However, an alternate form of multiplication known as tensor multiplication exists as well, and works more like you would expect matrix multiplication should. Let A be a p × q matrix and B be an n × m matrix, where neither A nor B is a 1 × 1 matrix. Then the tensor product Note that there is no restriction that the number of columns in the first matrix must equal the number of rows in the second, as there is with normal matrix multiplication. The object of this problem is to determine the number of ways (if any) a given matrix can be formed as a result of a tensor multiplication. Input The first line of input for a test case will contain two positive integers r and c indicating the number of rows and columns in the matrix. After this will follow r lines each containing c positive integers. The values of r and c will be ≤ 500, each entry in the matrix will be no greater than 65,536, and the last test case is followed by a line containing 0 0. Output For each test case, output the number of different ways the matrix could be the tensor product of two positive integer matrices, neither of which is a 1 × 1 matrix. Sample Input
Sample Output
Source | ||||||||||
|