Codeforces Round #440 (Div. 2)
codeforces 870 A. Search for Pretty Integers(水题)
题意:给两个数组,求一个最小的数包含两个数组各至少一个数。
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int n, m; 6 int a[11], b[11]; 7 int main() { 8 int i, j, x = 10, y = 10, s = 10; 9 scanf("%d%d", &n, &m); 10 for(i = 1; i <= n; ++i) { 11 scanf("%d", &a[i]); if(a[i] < x) x = a[i]; 12 } 13 for(i = 1; i <= m; ++i) { 14 scanf("%d", &b[i]); if(b[i] < y) y = b[i]; 15 for(j = 1; j <= n; ++j) 16 if(a[j] == b[i] && b[i] < s) s = b[i]; 17 } 18 if(s < 10) printf("%d\n", s); 19 else { 20 if(x > y) swap(x, y); 21 printf("%d%d\n", x, y); 22 } 23 return 0; 24 }