codeforces Search for Pretty Integers(水)
来源:互联网 发布:php redis auth 编辑:程序博客网 时间:2024/06/10 20:09
http://codeforces.com/contest/870/problem/A
题意:就是如果两个集合中有共同元素的话,就输出共同元素,如果没有共同元素的话就输出两个集合中的可以组成的最小的数。
思路:桶排水题。比较坑的是,两个有共同元素的时候输出共同元素。当时因为这个原因worng了两发,心态巨崩,然后代码写的也很丑 了,,
#include <stdio.h>#include <string.h>#include <algorithm>#include <queue>#include <stack>#include <iostream>using namespace std;int main(){int a[10],b[10];int n , m , t;scanf("%d%d",&n,&m);memset(a,0,sizeof(a));memset(b,0,sizeof(b));for(int i = 0 ; i < n; i++){scanf("%d",&t);a[t]++;}for(int i = 0 ; i < m; i ++){scanf("%d",&t);b[t]++;}for(int i = 0 ; i < 10 ;i++){if(a[i]&&b[i]){printf("%d",i);return 0;}}int o = 0,p = 0;for(int i = 0 ; i < 10 ; i++){if(a[i]){o = i;break;}}for(int i = 0 ; i < 10 ; i++){if(b[i]){p = i ;break;}}if(o>p){printf("%d%d",p,o);}else{printf("%d%d",o,p);}puts("");}
阅读全文
0 0
- codeforces Search for Pretty Integers(水)
- Codeforces 872 A Search for Pretty Integers
- CodeForces 872A Search for Pretty Integers
- Codeforces Round #440 div2 A. Search for Pretty Integers
- Codeforces Round #440 (Div. 2) Search for Pretty Integers
- Codeforces Round #440 A. Search for Pretty Integers
- A. Search for Pretty Integers
- Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination) A. Search for Pretty Integers
- Codeforces 870A. Search for Pretty Int
- Elimination Round 2-A. Search for Pretty Integers
- Codeforces Round #422 D. My pretty girl Noora (数论)
- CodeForces 616 A. Comparing Two Long Integers(水~)
- Codeforces 509E. Pretty Song
- Pretty Poem(substr)
- Codeforces Round #422 (Div. 2) D. My pretty girl Noora(数论)
- Codeforces 822 D. My pretty girl Noora(多项式加法+dp)
- Pretty Song - CodeForces 509 E 想法题
- codeforces 822D My pretty girl Noora
- Keil软件的介绍
- linux远程服务连接不上,或连接超时解决方法
- 第十单元(2)
- [Lintcode] #469 等价二叉树
- hdoj 5514 Frogs
- codeforces Search for Pretty Integers(水)
- 【MyBatis】动态SQL
- Spark Streaming 结合spark sql 计算UV / checkout
- PIL图像处理
- 格式化I/O(常用的 sprintf 和 sscanf 总结)
- 《结合卷积神经网络和超像素聚类的细胞图像分割方法》
- codeblocks配置caffe环境,调用caffe模型
- POJ3321:Apple Tree 树状数组 (一个点通过dfs变成两个值)
- Linux Shell 脚本编程(8)—文本过滤(awk命令)