1911: 【CSP二维数组】等比例缩放照片█

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:1 Solved:1

Description

如图所示的一张照片(图①),可以把它的宽度或者高度减小从而减少照片的尺寸(如图②、③、④)。但只有等比例缩放的情况下照片才是最好看的,如图④;图②照片被压扁,图③照片被拉长。

给定图片的原始尺寸以及n组要压缩的尺寸,请问哪组压缩后的数据的宽高比最接近原始数据?如果有多组压缩尺寸的宽高比都是一样的且都是最接近原始数据的,那么输出压缩后面积最小的那组数据。


Input

第 lns="http://www.w3.org/1998/Math/MathML">1 行, lns="http://www.w3.org/1998/Math/MathML">2 个整数 lns="http://www.w3.org/1998/Math/MathML">x 和 lns="http://www.w3.org/1998/Math/MathML">y ,代表图片的原始尺寸的宽和高

第 lns="http://www.w3.org/1998/Math/MathML">2 行,一个整数 lns="http://www.w3.org/1998/Math/MathML">n ,代表接下来有 lns="http://www.w3.org/1998/Math/MathML">n 组压缩后的尺寸( lns="http://www.w3.org/1998/Math/MathML">n100 )

接下来 lns="http://www.w3.org/1998/Math/MathML">n 行,每行 lns="http://www.w3.org/1998/Math/MathML">2 个数,代表 lns="http://www.w3.org/1998/Math/MathML">n 组压缩后的宽和高(确保输入的宽 lns="http://www.w3.org/1998/Math/MathML"> 高)(本题所有照片的宽高均在 lns="http://www.w3.org/1998/Math/MathML">110000 之间)

Output

宽高比和原始图片最接近的宽高数据,如果有多组这样的数,输出面积最小的那组(不存在多组宽高比和原始数据一样接近且面积又一样的数据)

Sample Input Copy

16 9
3
20 5
32 16
11 8

Sample Output Copy

32 16