#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x,y,ab,mj;
double a[110][4];
cin>>x>>y;
ab = x/y;
mj = x*y;
int n;
cin>>n;
for(int i = 0;i<n;i++)
{
cin>>a[i][0];
cin>>a[i][1];
a[i][2] = a[i][0]/a[i][1];
a[i][3] = a[i][0]*a[i][1];
}
double min = 9999999;
for(int i = 0;i<n;i++)
{
a[i][2] = abs(ab-a[i][2]);
if(a[i][2]<min)
{
min = a[i][2];
}
}
double min2 = 99999999;
for(int i = 0;i<n;i++)
{
if(a[i][2]==min)
{
if(a[i][3]<min2)
{
min2 = a[i][3];
}
}
}
cout<<endl;
for(int i = 0;i<n;i++)
{
if(a[i][3]==min2)
{
cout<<a[i][0]<<" "<<a[i][1];
return 0;
}
}
return 0;
}
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[110][110];
int b[110][110];
int c[110][110];
for(int i = 0;i<n;i++)
{
for(int j = 0;j<m;j++)
{
cin>>a[i][j];
}
}
for(int i = 0;i<n;i++)
{
for(int j = 0;j<m;j++)
{
cin>>b[i][j];
}
}
for(int i = 0;i<n;i++)
{
for(int j = 0;j<m;j++)
{
if(a[i][j]==0&&b[i][j]==0)
{
c[i][j] = 0;
}
else
{
c[i][j] = 1;
}
}
}
cout<<endl;
for(int i = 0;i<n;i++)
{
for(int j = 0;j<m;j++)
{
cout<<c[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x[110] = {0};
int y[110] = {0};
int sum[110] = {0};
int x1,y1;
cin>>x1>>y1;
int n;
cin>>n;
for(int i = 0;i<n;i++)
{
cin>>x[i]>>y[i];
if(x1!=x[i]||y1!=y[i])
{
int a = abs(x1-x[i]);
int b = abs(y1-y[i]);
sum[i] = a+b;
}
else
{
sum[i] = 9999;
}
}
int min = 999999;
for(int i = 0;i<n;i++)
{
if(sum[i]<min)
{
min = sum[i];
}
}
int min2 = 999999;
for(int i = 0;i<n;i++)
{
int sum2 = x[i]+y[i];
if(sum[i]==min)
{
if(sum2<min2)
{
min2 = sum2;
}
}
}
for(int i = 0;i<n;i++)
{
int sum2 = x[i]+y[i];
if(sum[i]==min)
{
if(sum2==min2)
{
cout<<x[i]<<" "<<y[i];
return 0;
}
}
}
return 0;
}