博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CF870A Search for Pretty Integers
阅读量:4331 次
发布时间:2019-06-06

本文共 1830 字,大约阅读时间需要 6 分钟。

题意翻译

给出两个整数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 34 25 7 6
输出样例#1: 
25
输入样例#2: 
8 81 2 3 4 5 6 7 88 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
#include
#include
#include
#include
using namespace std;int n,m;int a[11],b[11];int main(){ cin>>n>>m; for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=1;i<=m;i++) scanf("%d",&b[i]); sort(a+1,a+1+n); sort(b+1,b+1+m); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(a[i]==b[j]){ cout<
<
b[1]) cout<
<

 

转载于:https://www.cnblogs.com/cangT-Tlan/p/8442612.html

你可能感兴趣的文章
敏捷开发中软件测试团队的职责和产出是什么?
查看>>
在mvc3中使用ffmpeg对上传视频进行截图和转换格式
查看>>
python的字符串内建函数
查看>>
Spring - DI
查看>>
微软自己的官网介绍 SSL 参数相关
查看>>
Composite UI Application Block (CAB) 概念和术语
查看>>
ajax跨域,携带cookie
查看>>
阶段3 2.Spring_01.Spring框架简介_03.spring概述
查看>>
阶段3 2.Spring_02.程序间耦合_1 编写jdbc的工程代码用于分析程序的耦合
查看>>
阶段3 2.Spring_01.Spring框架简介_04.spring发展历程
查看>>
阶段3 2.Spring_02.程序间耦合_3 程序的耦合和解耦的思路分析1
查看>>
阶段3 2.Spring_02.程序间耦合_5 编写工厂类和配置文件
查看>>
阶段3 2.Spring_01.Spring框架简介_05.spring的优势
查看>>
阶段3 2.Spring_02.程序间耦合_7 分析工厂模式中的问题并改造
查看>>
阶段3 2.Spring_02.程序间耦合_4 曾经代码中的问题分析
查看>>
阶段3 2.Spring_03.Spring的 IOC 和 DI_2 spring中的Ioc前期准备
查看>>
阶段3 2.Spring_03.Spring的 IOC 和 DI_4 ApplicationContext的三个实现类
查看>>
阶段3 2.Spring_02.程序间耦合_8 工厂模式解耦的升级版
查看>>
阶段3 2.Spring_03.Spring的 IOC 和 DI_6 spring中bean的细节之三种创建Bean对象的方式
查看>>
阶段3 2.Spring_04.Spring的常用注解_3 用于创建的Component注解
查看>>