1 2 3 4 5 6 7 8 9 10 11 12
| #include <cstdio> int a[10],b[10],n,m,x,y; int main(void){ scanf ("%d%d",&n,&m); for (int i=0;i<n;i++)scanf ("%d",&x),a[x]=1; for (int i=0;i<m;i++)scanf ("%d",&x),b[x]=1; for (int i=1;i<10;i++)if (a[i]&&b[i])return !printf ("%d",i); for (int i=1;i<10;i++)if (a[i]){x=i;break;} for (int i=1;i<10;i++)if (b[i]){y=i;break;} if (x<y)printf ("%d",x*10+y); else printf ("%d",y*10+x); }
|