当前位置:网站首页>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;
}
边栏推荐
- Take you hand in hand to build feign with idea
- New potential energy of industrial integration, Xiamen station of city chain technology digital summit successfully held
- UE4_ Ue5 panoramic camera
- Ora-02437 failed to verify the primary key violation
- 数据库面试题+解析
- USB (XIV) 2022-04-12
- SLAM面试总结
- Extended tree (I) - graphic analysis and C language implementation
- Markdown
- Progress broadcast | all 29 shield machines of Guangzhou Metro Line 7 have been launched
猜你喜欢
SAP HR 劳动合同信息 0016
MySQL Index Optimization Practice II
ping报错:未知的名称或服务
C method question 1
B_QuRT_User_Guide(38)
Digital procurement management system for fresh food industry: help fresh food enterprises solve procurement problems and implement online procurement throughout the process
Live-Server使用
SAP HR 家庭成员信息
2022注册测绘师备考开始 还在不知所措?手把手教你怎么考?
How to change the formula picture in the paper directly into the formula in word
随机推荐
Take you hand in hand to build Eureka client with idea
SAP HR 社会工作经历 0023
B_QuRT_User_Guide(40)
Senior programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization, and recommends collecting
Illegal behavior analysis 1
List. How to achieve ascending and descending sort() 2020.8.6
Possible SQL for Oracle table lookup information
B / Qurt Utilisateur Guide (36)
Navicat connects Oracle
Anxinco esp32-a1s development board is adapted to Baidu dueros routine to realize online voice function
Mobile heterogeneous computing technology - GPU OpenCL programming (basic)
Reverse output three digit and arithmetic sequence
FPGA basics catalog
Dependency injection
C cat and dog
First week of July
MySQL Architecture
企业应用需求导向开发之人力部门,员工考勤记录和实发工资业务程序案例
As a new force, chenglian premium products was initially injected, and the shares of relevant listed companies rose 150% in response
2022 certified surveyors are still at a loss when preparing for the exam? Teach you how to take the exam hand in hand?