当前位置:网站首页>Jisuan Ke - t3104
Jisuan Ke - t3104
2022-07-07 23:39:00 【Yuesi】
Garlic maker T3104
subject
Small B Here are two integers , Please find the public number in the two numbers .
A public number is a number that appears in both integers .
As long as your program is 1s Results found in , He can use these numbers to do a magic trick for you .
Input format
Two integers in a row .
Output format
A few numbers in a row , Represents a public number , The numbers are separated by spaces .
The output should be from small to large according to the size of the number .
If it doesn't exist , The output -1.
Data range
Let the larger of the two numbers be n
:
about 50% The data of ,0≤n≤10^9.
about 80% The data of ,0≤n≤1018.
about 90% The data of ,0≤n≤10(104).
about 100% The data of ,0≤n≤10(106).
#include<iostream>
using namespace std;
int main(){
string a,b;
// When the number is too large, it can be read in the form of string
cin>>a;
cin>>b;
long long int l1=a.length(),l2=b.length();
// Calculate the string length , Pay attention to the data range
long long int a1[100]={
0},b1[100]={
0};
// Record two strings respectively 0-9 Number of occurrences
int t=0;
for(long long int i=0;i<l1;i++){
a1[(a[i]-'0')]++;
// Record the first read string a in 0-9 Number of occurrences of each number
}
for(long long int i=0;i<l2;i++){
b1[(b[i]-'0')]++;
// Record the next read string b in 0-9 Number of occurrences of each number
}
for(int i=0;i<10;i++){
if(a1[i]>0&&b1[i]>0){
// Judge whether there are characters in both strings (0-9)
if(t>0){
// Used to control output spaces
printf(" ");
}
printf("%d",i);
t++;
}
if(i==9&&t==0){
// If two strings do not have the same character
printf("-1\n");
}
}
return 0;
}
边栏推荐
- Dataguard 主备清理归档设置
- Anxin vb01 offline voice module access intelligent curtain guidance
- Access database query all tables SQL
- Three questions TDM
- How can we make money by making video clips from our media?
- USB (XVIII) 2022-04-17
- Right click the idea file to create new. There is no solution to create new servlet
- List. How to achieve ascending and descending sort() 2020.8.6
- SAP HR 家庭成员信息
- C method question 2
猜你喜欢

Navicat connects Oracle

SAP 内存参数调优过程

Home appliance industry channel business collaboration system solution: help home appliance enterprises quickly realize the Internet of channels
![[experiment sharing] log in to Cisco devices through the console port](/img/e4/fc72ed57de74a0dd51c484a1c2f348.png)
[experiment sharing] log in to Cisco devices through the console port

Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f

95.(cesium篇)cesium动态单体化-3D建筑物(楼栋)

B_ QuRT_ User_ Guide(37)

MySQL架构
postgis学习

包装行业智能供应链S2B2B商城解决方案:开辟电商消费新生态
随机推荐
648. Word replacement
Three questions TDM
C语言学习
The file format and extension of XLS do not match
How to change the formula picture in the paper directly into the formula in word
Given an array, such as [7864, 284, 347, 7732, 8498], now you need to splice the numbers in the array to return the "largest possible number."
【汇总】看过的一些Panel与视频
Navicat connects Oracle
[compilation principle] lexical analysis design and Implementation
[experiment sharing] log in to Cisco devices through the console port
Anxinco esp32-a1s development board is adapted to Baidu dueros routine to realize online voice function
生鲜行业数字化采购管理系统:助力生鲜企业解决采购难题,全程线上化采购执行
平衡二叉樹【AVL樹】——插入、删除
SAP HR 社会工作经历 0023
B_QuRT_User_Guide(38)
建筑建材行业SRM供应商云协同管理平台解决方案,实现业务应用可扩展可配置
C method question 1
StringUtils工具类
二叉排序树【BST】——创建、查找、删除、输出
USB (XVI) 2022-04-28