Task DescriptionDiscussion (0)
Input:
Output:
Input:
Output:
Task :: BubbleMatrix
A perfect matrix is a matrix with integer elements in which each two neighboring elements are relatively prime (co-prime), and the absolute value of each element is greater than one. Each element has up to four neighbors.
You are given a matrix A_(m×n) with integer elements a[i][j],1≤i≤m,1≤j≤n.
Check if there exists a perfect matrixB_(m×n) where b[i][j] divides a[i][j] for every 1≤i≤m,1≤j≤n.
You are given a matrix A_(m×n) with integer elements a[i][j],1≤i≤m,1≤j≤n.
Check if there exists a perfect matrixB_(m×n) where b[i][j] divides a[i][j] for every 1≤i≤m,1≤j≤n.
INPUT:
The first line contains positive integers m,n (1≤m,n≤80) — the dimensions of the matrix A_(m×n). Each of the next m lines contains a sequence of n integers separated by spaces, representing elements a[i][j] (2≤|a[i[j]|≤1000) of the matrix A_(m×n).
The first line contains positive integers m,n (1≤m,n≤80) — the dimensions of the matrix A_(m×n). Each of the next m lines contains a sequence of n integers separated by spaces, representing elements a[i][j] (2≤|a[i[j]|≤1000) of the matrix A_(m×n).
OUTPUT:
Output consists of one digit: “yes” (without quotes) if a perfect matrix exists; “no” if it doesn’t exist.
Output consists of one digit: “yes” (without quotes) if a perfect matrix exists; “no” if it doesn’t exist.
Input:
2 2
6 4
10 9
6 4
10 9
Output:
yes
Input:
1 3
4 6 9
4 6 9
Output:
no
Submit Solution
Home
Training
Competitions
Forum
FAQ