当前位置:网站首页>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;
}
边栏推荐
- [STM32 + esp-12s connect Tencent cloud IOT development platform 1] creation of cloud platform and burning of at firmware
- C method question 2
- [stm32+esp8266 connect Tencent cloud IOT development platform 2] stm32+esp8266-01s connect Tencent cloud
- 【路径规划】使用垂距限值法与贝塞尔优化A星路径
- Boost regex library source code compilation
- UE4_ Ue5 panoramic camera
- Idea automatically generates serialVersionUID
- Flash encryption process and implementation of esp32
- USB (XV) 2022-04-14
- Enumeration, simulation, and sorting
猜你喜欢

C inheritance and interface design polymorphism
![Arbre binaire équilibré [Arbre AVL] - Insérer et supprimer](/img/1f/cd38b7c6f00f2b3e85d4560181a9d2.png)
Arbre binaire équilibré [Arbre AVL] - Insérer et supprimer

Class C design questions

Summary of SQL single table query 2020.7.27
![[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

B_QuRT_User_Guide(38)

Interface

UE4_ Ue5 combined with Logitech handle (F710) use record

SAP HR reward and punishment information export
![[STM32 + esp-12s connect Tencent cloud IOT development platform 1] creation of cloud platform and burning of at firmware](/img/bc/8241a339cca9b7af475169dba39c10.jpg)
[STM32 + esp-12s connect Tencent cloud IOT development platform 1] creation of cloud platform and burning of at firmware
随机推荐
MongoDB快速入门
Dependency injection 2 advantage lifecycle
高效的S2B2C电商系统,是这样帮助电子材料企业提升应变能力的
ESP at installation esp8266 and esp32 versions
Summary of common methods of object class (September 14, 2020)
[experiment sharing] log in to Cisco devices through the console port
As a new force, chenglian premium products was initially injected, and the shares of relevant listed companies rose 150% in response
[untitled]
Understand TCP's three handshakes and four waves with love
【7.5】15. 三数之和
gorm 关联关系小结
[compilation principle] lexical analysis design and Implementation
Live server usage
Fibonacci number of dynamic programming
[summary] some panels and videos seen
Extended tree (I) - graphic analysis and C language implementation
电子设备行业智能供应链协同平台解决方案:解决低效, 赋能产业数字化升级
Ora-02437 failed to verify the primary key violation
B_ QuRT_ User_ Guide(37)
Open source hardware small project: anxinco esp-c3f control ws2812