题意翻译

给出两个整数n,m,a数组有n个数,b数组有m个数。求一个数,这个数的每一位必须在a数组和b数组中至少出现过一次,求符合条件的数当中最小的数。

Translated by @我是lyy

题目描述

You are given two lists of non-zero digits.

Let's call an integer pretty if its (base 1010 ) representation has at least one digit from the first list and at least one digit from the second list. What is the smallest positive pretty integer?

输入输出格式

输入格式:

The first line contains two integers nn and mm ( 1<=n,m<=91<=n,m<=9 ) — the lengths of the first and the second lists, respectively.

The second line contains nn distinct digits a_{1},a_{2},...,a_{n}a1​,a2​,...,an​ ( 1<=a_{i}<=91<=ai​<=9 ) — the elements of the first list.

The third line contains mm distinct digits b_{1},b_{2},...,b_{m}b1​,b2​,...,bm​ ( 1<=b_{i}<=91<=bi​<=9 ) — the elements of the second list.

输出格式:

Print the smallest pretty integer.

输入输出样例

输入样例#1: 复制

2 3
4 2
5 7 6
输出样例#1: 复制

25
输入样例#2: 复制

8 8
1 2 3 4 5 6 7 8
8 7 6 5 4 3 2 1
输出样例#2: 复制

1

说明

In the first example 2525 , 4646 , 2456724567 are pretty, as well as many other integers. The smallest among them is 2525 . 4242 and 2424are not pretty because they don't have digits from the second list.

In the second example all integers that have at least one digit different from 99 are pretty. It's obvious that the smallest among them is 11 , because it's the smallest positive integer.

#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m;
int a[],b[];
int main(){
cin>>n>>m;
for(int i=;i<=n;i++) scanf("%d",&a[i]);
for(int i=;i<=m;i++) scanf("%d",&b[i]);
sort(a+,a++n);
sort(b+,b++m);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
if(a[i]==b[j]){
cout<<a[i]<<endl;
return ;
}
if(a[]>b[]) cout<<b[]*+a[]<<endl;
else cout<<a[]*+b[]<<endl;
}

最新文章

  1. Tomcat并发数优化,修改service.xml性能调优 增加最大并发连接数
  2. python 协程
  3. 初试Nodejs——使用keystonejs创建博客网站1(安装keystonejs)
  4. Docker 容器中“TERM environment variable not set.”问题解决
  5. Web开发者宝典:10款流行前沿矢量图形素材
  6. [Angular 2] Simple intro Http
  7. 在ASP.NET MVC中使用 Bootstrap table插件
  8. Loadrunner错误 -27727: 下载资源时步骤下载超时 (120 seconds) 已过期
  9. linux网路编程:字节序(大端、小端、网络、主机)
  10. Sqlserver 事务处理模板
  11. mac 安装protobuf,并编译为java,c++,python
  12. iOS证书申请及使用详细说明
  13. 如何将云原生工作负载映射到 Kubernetes 中的控制器
  14. POJ 2253 Frogger (Floyd)
  15. Ubuntu 安装 H3C iNode 客户端
  16. python基础学习2
  17. 神经网络中Epoch、Iteration、Batchsize相关理解
  18. Ext4文件系统架构分析(三) ——目录哈希、扩展属性与日志
  19. Python爬虫之requests库介绍(一)
  20. 多页面应用_vue

热门文章

  1. HDU--1558--Segment set--并查集***经典***
  2. c28---const
  3. ijkplayer视频播放
  4. nyoj--105--九的余数(水题)
  5. net快速写入/读取大量数据Postgresql
  6. ASP.NET MVC上传文件 未显示页面,因为请求实体过大。解方案
  7. Java中将JSON格式的数据转换成对应的Bean、Map、List数据
  8. caffe特征提取/C++数据格式转换
  9. C# 生成Model和DAL
  10. VMware虚拟机共享文件夹问题: /mnt下没有hgfs文件夹