Area
Time limit1sMemory limit2048 MB
Given the areas of the long and short diagonal plots in an N by N grid, find the area of the plot at column X, row Y as a prime factorization.
- Level
Medium5 of 10
- Topics
- Math, Number theory
- Solved
- No attempts yet
Problem
A square field has been divided into rectangular plots by drawing vertical and horizontal lines. The rows of plots are numbered from bottom to top, and the columns are numbered from left to right, as shown in the figures below. The figures are not to scale.

The plots at the intersection of the -th column and the -th row () form the long diagonal. The plots at the intersection of the -st column and the -th row () form the short diagonal.
You know the areas of the plots on both diagonals. Find the area of the plot at the intersection of the -th column and the -th row.
Input
The first line contains an integer ().
The second line contains integers (), the areas of the plots on the long diagonal.
The third line contains integers (), the areas of the plots on the short diagonal.
The fourth line contains two integers and (), the coordinates of the plot whose area you need.
Output
Let be the area of the plot. Print as a list of lines, each with two integers and . Each is a distinct prime, and each is a non-zero integer, such that , where is the number of lines. List the lines in increasing order of .
If , print a single line "1 1".