Codeforces Round #440 A. Search for Pretty Integers

NYIST_2013寒假ACM集训队练习赛(2) 集训第二周周四,做出来了7道题目,题目非常水,还有几道没有A出来的也不难,完了花点时间水一下,a过的题目贴在这里。没有a的后面补上。 比赛链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=39441#overview 密码:nyist I - I Time Limit:1000MS     Memory Limit:32 阅读详情
A. Search for Pretty Integers
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given two lists of non-zero digits.

Let's call an integer pretty if its (base 10) 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?

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 9) — the lengths of the first and the second lists, respectively.

The second line contains n distinct digits a1, a2, ..., an (1 ≤ ai ≤ 9) — the elements of the first list.

The third line contains m distinct digits b1, b2, ..., bm (1 ≤ bi ≤ 9) — the elements of the second list.

Output

Print the smallest pretty integer.

Examples
input
2 3
4 2
5 7 6
output
25
input
8 8
1 2 3 4 5 6 7 8
8 7 6 5 4 3 2 1
output
1
Note

In the first example 25, 46, 24567 are pretty, as well as many other integers. The smallest among them is 25. 42 and 24 are 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 9 are pretty. It's obvious that the smallest among them is 1, because it's the smallest positive integer.

水题,找最小的数要么在两个数组里头出现过,要么由两个数组中的数组成

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int a[15],b[15];
long long ff(long long q1,long long q2)
{
    int s=0;
    long long t=q2;
    while(t)
    {
        t=t/10;
        s++;
    }
    return q1*((long long)(pow(10,s)))+q2;
}
int main() {
    int x,y;
    cin>>x>>y;
    for (int i=1; i<=x; i++) {
        cin>>a[i];
    }
    for (int i=1; i<=y; i++) {
        cin>>b[i];
    }
    sort(a+1, a+x+1);
    sort(b+1, b+y+1);
    bool f=false;
    long long t=1e9+7;
    for(int i=1;i<=x;i++)
    {
        for (int j=1; j<=y; j++) {
            if(a[i]==b[j])
            {
                f=true;
                t=a[i];
                break;
            }
        }
        if(f)
            break;
    }
    t=min(t,min(ff(a[1],b[1]),ff(b[1],a[1])));
    cout<<t<<endl;
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}



从零开始搭建水质监测系统:STM32+Lora+4G的物联网应用详解 本文详细介绍了如何从零开始搭建一个基于STM32、LoRa和4G技术的工业级水质监测物联网系统。文章深入剖析了系统架构设计、核心硬件选型(如STM32F103系列MCU)、关键电路接口、嵌入式软件驱动开发、多任务调度以及云端数据集成与可视化的完整实战流程,为智慧农业、环境监测等领域的物联网应用提供了宝贵的“避坑指南”和解决方案。 阅读详情

相关推荐

win11重装系统简易教程-小白也可以上手!

本文介绍一下win11系统重装的各个步骤,也作为记录供自己后面查看。附上我之前参考的一位知乎大神写的重装win10系统文章的地址本文用到的工具全部是,不需要下载第三方镜像文件(不是说这个不好,只是第三方的软件或镜像文件网上非常多,琳琅满目,小白需要筛选甄别,直接用官方的就比较省心,大神请自便~)

Sddqa的博客 1万+

A. Search for Pretty Integers

time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given two lists of non-zero digits. Let's call an inte

无知的我 879

AD9361 官方例程详解(一)

文章目录前言一、pandas是什么?二、使用步骤总结 前言 一、pandas是什么? 二、使用步骤 总结

weixin_44630490的博客 4万+

Codeforces Round #440 div2 A. Search for Pretty Integers

A. Search for Pretty Integers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given two lists of non

Star77777的博客 544

Anaconda报错no qt platform plugin could be initialized

今天因为在anaconda中安装了一个新包,安装成功后运行python 程序报错:no qt platform plugin could be initialized。 1.安装Anaconda3-4.2.0-Windows-x86_64,对应python版本为3.5.2,scikit learn版本是0.17。因为要用Isolation Forest算法,只有0.18以上版本scikit learn才包含此算法,所以想更新scikit learn。 conda install scikit-lear

zhang1806618的博客 1万+

手把手教你模拟登录豆瓣并爬取个人书影音数据:从Cookie解析到反爬攻防实战

在开始写代码之前,先明确我们需要的工具。:建议用3.10以上版本,方便使用一些新特性(如match语句)httpx:比requests更现代,支持HTTP/2,异步性能强,连接池复用好:解析HTML,语法简单,容错性强selenium:仅用于处理登录时的滑块验证(模拟真人)pandas:最终数据清洗和导出Excel/CSVretrying:自动重试机制,应对临时封禁:随机UA,降低特征lxml:作为BeautifulSoup的解析器,速度快为什么不只用requests?

2201_76125261的博客 577

codeforces 872aSearch for Pretty Integers

http://www.elijahqi.win/archives/1253 You are given two lists of non-zero digits. Let’s call an integer pretty if its (base 10) representation has at least one digit from the first list and at leas...

Elijahqi 300

【人工智能】Cursor模型被封?两步教你破解

Cursor模型全线被禁,主流模型如Claude、GPT-4无法访问,仅剩Deepseek等基础模型可用。官方证实限制源于上游API区域政策,提供三种"无效"解决方案引发用户不满。社区发现有效解决方式:需同时开启全局代理和将Cursor网络设置改为HTTP/1.1协议,详细步骤包括修改用户设置和完全重启程序。另有SOCKS5代理配置方案供高级用户选择。技术原理推测HTTP/1.1可绕过区域检测。用户面临继续使用或转投其他工具的选择,社区交流受限但仍有讨论。

奶爸的编程之路,也就一周冷个三天 2194

Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2)

A. Search for Pretty Integers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given two lists of non

Algorithm_Art的博客 647

声音源定位:利用YOLO与麦克风阵列定位声音来源YOLOv5、YOLOv8、YOLOv10

YOLO(You Only Look Once)是一个用于目标检测的深度学习模型。YOLO的最大特点是其通过一次前向传播即可完成多个目标的检测,速度和精度相对其他目标检测算法具有显著优势。YOLO模型的版本不断更新,从YOLOv1到YOLOv10,算法精度和速度都有了显著的提升。声音源定位是利用多个麦克风阵列收集的声音信号,通过算法计算声音源的位置。声音源定位的关键在于准确估计每个麦克风的声音到达时间,从而确定声音源的空间坐标。基于时延估计(TDOA)

YOLO 673

低功耗设计:如何计算power switch的数量?

power switch加多了漏电高,加少了ir drop会有问题,具体加多少合适要如何计算呢?这里可以给一个参考方式。 第一步,先选switch cell的类型 通常选用HVT类型的switch cell,优点是漏电更低,缺点也很明显,电阻大,压降也大,switch cell的大小选择,可以选择(开启电阻x面积)最小的switch cell,即单位面积提供最小并联电阻的cell类型。 第二步,计算数量 选好类型,确定了开启电阻,可以按照如下公式计算数量: Ron/Xnum • W/V = V•P

m0_61544122的博客 3577

Codeforces Round #440 (A-C ) 题解

A 题 A. Search for Pretty Integers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given two lists o...

weixin_30677073的博客 179

uniapp [安卓苹果App端] - 详细实现自定义水印相机功能,调用手机摄像头打开相机并在周围悬挂自定义水印,使用相机拍照后添加水印文字或样式,uniapp APP端水印相机完整源码,兼容强大可靠

uni-app,安卓Android,苹果ios,安卓app端,苹果App端,uniapp苹果app,水印相机,uniapp水印相机,Uniapp安卓app实现水印相机,uniapp苹果ios水印相机,打开系统相机拍照添加水印,地点打卡相机,水印相机(水印照片,图片加水印),uniapp自定义水印相机,制作水印相机给图片添加水印并且保存图片至本地,uniapp拍照图片加水印,水印相机功能,手机调起摄像头拍照时自动插入文字、图片动态水印效果,支持水印显示拍摄者当前城市定位、自由调整水印大小和位置,手机拍照时

🏆 前端领域优质创作者 1万+

Codeforces Round #440 A. Search for Pretty Integers

题目链接:http://codeforces.com/contest/872/problem/A 题意:给你两个集合,输出一个由这两个集合的数组成的最小数,注意:有相同数的话,可能只有一位 思路:分别找出两个集合中的相同的数,其次找出两个集合中最小的数,如果有相同数集不为空,那么就输出其中最小的数,否则就是这两个最小的数组成的最小数(小的放前面) AC代码:#include #includ

可我只是梦呓,半生半生的无力 209

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

【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...

AWCXV 99

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

codeforces Round #440 A Search for Pretty Integers【hash/排序】

A. Search for Pretty Integers 【题目链接】:http://codeforces.com/contest/872/problem/A time limit per test 1 second memory limit per test 256 megabytes input standard input output standar...

weixin_33850015的博客 100

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination) A. Search for Pretty Integers

A. Search for Pretty IntegersProblem Statement     You are given two lists of non-zero digits.     Let’s call an integer pretty if its (base 10) representation has at least one digit from the firs

Ephemeral 319

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

A. Search for Pretty Integers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given two lists of non

0.0 403

Codeforces 870A. Search for Pretty Int

A. Search for Pretty Integers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given two lists of non

shyoldman的博客 626

codeforces Search for Pretty Integers(水)

http://codeforces.com/contest/870/problem/A 题意:就是如果两个集合中有共同元素的话,就输出共同元素,如果没有共同元素的话就输出两个集合中的可以组成的最小的数。 思路:桶排水题。比较坑的是,两个有共同元素的时候输出共同元素。当时因为这个原因worng了两发,心态巨崩,然后代码写的也很丑 了,, #include #include #inc

wjmwsgj的博客 410

Codeforces Round #440 div2 C. Maximum splitting

C. Maximum splitting time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given several queries. In the

Star77777的博客 488

CodeForces 872A Search for Pretty Integers

题目链接:http://codeforces.com/contest/872/problem/A 题意:给你两个序列,一个长度为n的序列a,和长度为m的序列b,现在给你一个定义叫做漂亮数,漂亮数至少有一个数是来自a序列,至少有一个数来自b序列,现让你输出最小的漂亮数 解析:有为a和b序列的范围0~9,所以最小的漂亮数一定是两位数,那你从1到100枚举一下,判断是否合法即可#include <bi

22h's Blog 582

Codeforces 872 A Search for Pretty Integers

题目地址 题意:给你两个集合a和b,容量分别为n和m,让你求出最小的数,包含了a中的一个数以及b中的一个数。 思路:排序+标记,我们先看有没有同时在a和b中出现的数,如果有的话,选最小的一个同时出现的数输出,如果没有的话就是把a和b集合分别排序,去每个集合中的最小值出来,然后二者的最小值当第一位,大者当后一位。

不要錯過才珍惜 501

【LDU】2017级个人训练赛#1

A - The Artful Expedient http://codeforces.com/problemset/problem/869/A Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissor

Z_sea的博客 705

Codeforces Round #440

You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum num

yqdjl6的博客 436
上一篇: Codeforces Round #438 C. Qualification Rounds
下一篇: Codeforces Round #440 B. Maximum of Maximums of Minimums
aaakirito
博客等级 码龄10年 172粉丝 160原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值