Oxymoron
Medium
Execution time limit is 1 second
Runtime memory usage limit is 122.486 megabytes
Three square matrices of the same size are provided. Your task is to determine if the third matrix is the result of multiplying the first matrix by the second matrix, in that specific order.
Input
The input consists of multiple test cases. Each test case starts with an integer n (1 ≤ n ≤ 500), which represents the size of the matrices. This is followed by the details of three matrices, each consisting of n rows with n integers per row. All integers in the input are no greater than 10^9
. The input concludes with a test case where n = 0, which should not be processed.
Output
For each test case, output YES if the third matrix is the product of the first and second matrices. Otherwise, output NO.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 8%