【Codeforces Round #440 (Div. 2) A】 Search for Pretty Integers

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

先枚举一个数字的情况。 再枚举两个数的情况就好。

【代码】

#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int N = 20;

int a[N],b[N],n,m;

int main()
{
    //freopen("F:\rush.txt","r",stdin);
    scanf("%d%d",&n,&m);
    for (int i = 1;i <= n;i++)
    {
        int x;
        scanf("%d",&x);
        a[x]++;
    }
    for (int i = 1;i <= m;i++)
    {
        int x;
        scanf("%d",&x);
        b[x]++;
    }
    for (int i = 1;i <= 9;i++)
        if (a[i]>0&&b[i]>0)
        {
            printf("%d
",i);
            return 0;
        }
    for (int i = 1;i <= 9;i++)
        for (int j = 1;j <= 9;j++)
            if ( (a[i]>0 || a[j]>0) && (b[i]>0||b[j]>0))
            {
                printf("%d
",i*10+j);
                return 0;
            }
    return 0;
}
原文地址:https://www.cnblogs.com/AWCXV/p/7673827.html