当前位置:网站首页>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;
}
边栏推荐
- Summary of common methods of object class (September 14, 2020)
- USB (XVIII) 2022-04-17
- 包装行业智能供应链S2B2B商城解决方案:开辟电商消费新生态
- 企业应用需求导向开发之人力部门,员工考勤记录和实发工资业务程序案例
- Anti climbing means cracking the second
- Illegal behavior analysis 1
- Extended tree (I) - graphic analysis and C language implementation
- IDEA 2021.3. X cracking
- C - minute number V3
- C simple question one
猜你喜欢

ping报错:未知的名称或服务

USB (XV) 2022-04-14

2022注册测绘师备考开始 还在不知所措?手把手教你怎么考?

Take you hand in hand to build Eureka client with idea

【实验分享】通过Console口登录到Cisco设备

进度播报|广州地铁七号线全线29台盾构机全部完成始发

Right click the idea file to create new. There is no solution to create new servlet
![[stm32+esp8266 connects to Tencent cloud IOT development platform 3] stm32+esp8266-01s dynamically registers devices on Tencent cloud (at instruction mode) -- with source code](/img/55/ab50ead2564498cb214d98ac5b9c3d.jpg)
[stm32+esp8266 connects to Tencent cloud IOT development platform 3] stm32+esp8266-01s dynamically registers devices on Tencent cloud (at instruction mode) -- with source code

Anxinco EC series modules are connected to the multi protocol access products of onenet Internet of things open platform
postgis学习
随机推荐
S2b2b mall solution of intelligent supply chain in packaging industry: opening up a new ecosystem of e-commerce consumption
[summary] some panels and videos seen
Progress broadcast | all 29 shield machines of Guangzhou Metro Line 7 have been launched
Access database query all tables SQL
激光slam学习(2D/3D、偏实践)
C simple question one
关于CH32库函数与STM32库函数的区别
KeePass realizes automatic input of web pages
[stm32+esp8266 connects to Tencent cloud IOT development platform 3] stm32+esp8266-01s dynamically registers devices on Tencent cloud (at instruction mode) -- with source code
What if once again forgets the login password of raspberry pie? And you don't have a monitor yet! Today, I would like to introduce a method
通达信买基金安全吗?
SLAM面试总结
Anxinco EC series modules are connected to the multi protocol access products of onenet Internet of things open platform
Take you hand in hand to build Eureka client with idea
UE4_ Ue5 panoramic camera
Take you hand in hand to build feign with idea
【leetcode】day1
MySQL Index Optimization Practice II
C method question 1
redis缓存工具类,值得拥有~