当前位置:网站首页>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;
}
边栏推荐
- C inheritance and interface design polymorphism
- Design and implementation of spark offline development framework
- 【leetcode】day1
- Anxinco esp32-a1s development board is adapted to Baidu dueros routine to realize online voice function
- Slam interview summary
- One week learning summary of STL Standard Template Library
- C simple question 2
- Enumeration, simulation, and sorting
- Balanced binary tree [AVL tree] - insert, delete
- 2022注册测绘师备考开始 还在不知所措?手把手教你怎么考?
猜你喜欢
平衡二叉树【AVL树】——插入、删除
2022 Season 6 perfect children's model Shaanxi finals came to a successful conclusion
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."
SRM supplier cloud collaborative management platform solution for building materials industry to realize business application scalability and configuration
SAP HR 劳动合同信息 0016
Extended tree (I) - graphic analysis and C language implementation
Progress broadcast | all 29 shield machines of Guangzhou Metro Line 7 have been launched
B_QuRT_User_Guide(36)
Markdown
C number of words, plus ¥, longest word, average value
随机推荐
电子设备行业智能供应链协同平台解决方案:解决低效, 赋能产业数字化升级
webflux - webclient Connect reset by peer Error
USB (XVI) 2022-04-28
Installing gradle
[stm32+esp8266 connect Tencent cloud IOT development platform 2] stm32+esp8266-01s connect Tencent cloud
The for loop realizes 1-100 addition and eliminates the 4-digit tail number
Anxinco esp32-a1s development board is adapted to Baidu dueros routine to realize online voice function
SAP 内存参数调优过程
USB (XVII) 2022-04-15
One week learning summary of STL Standard Template Library
redis缓存工具类,值得拥有~
包装行业智能供应链S2B2B商城解决方案:开辟电商消费新生态
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
SAP HR labor contract information 0016
Take you hand in hand to build feign with idea
Svn relocation
Three questions TDM
【汇总】看过的一些Panel与视频
2022 Season 6 perfect children's model Shaanxi finals came to a successful conclusion