AcWing 3577. 选择数字
原题链接
简单
作者:
未名湖畔的梦
,
2021-06-01 15:48:09
,
所有人可见
,
阅读 222
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m;
int x[N], y[N];
int p[N * 2], q[N * 2];
inline int read(int &x){
x = 0; char ch = getchar();
while(ch < '0' || ch > '9') ch = getchar();
while(ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return x ;
}
int main(){
read(n);
for(int i = 1; i <= n; i++) read(x[i]),p[x[i]] ++;
read(m);
for(int i = 1; i <= m; i++) read(y[i]),q[y[i]]++;
// for(int i = 1; i <= n; i++) printf("%d ",x[i]); puts("");
// for(int i = 1; i <= m; i++) printf("%d ",y[i]); puts("");
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(!p[x[i] + y[j]] && !q[x[i] + y[j]]){
printf("%d %d\n",x[i], y[j]);
return 0;
}
}
}
return 0;
}