当前位置:网站首页>1016 part a+b (15 points)
1016 part a+b (15 points)
2022-06-13 05:54:00 【Python's path to becoming a God】
Positive integer A Of “DA( by 1 An integer ) part ” Defined by A All in DA A new integer composed of PA. for example : Given A=3862767,DA=6, be A Of “6 part ”PA yes 66, because A There is 2 individual 6.
Now given A、DA、B、DB, Please write a program to calculate PA+PB.
Input format :
The input is given in turn on a line A、DA、B、DB, Space between , among 0<A,B<109.
Output format :
Output in one line PA+PB Value .
sample input 1:
3862767 6 13530293 3
sample output 1:
399
sample input 2:
3862767 1 13530293 8
sample output 2:
0Small simulation No difficulty
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
vector<int> a, b;
int main()
{
long long m, x, n, y;
cin >> x >> m >> y >> n;
while(x)
{
if(x % 10 == m) a.push_back(m);
x /= 10;
}
while(y)
{
if(y % 10 == n) b.push_back(n);
y /= 10;
}
int sum1 = 0, sum2 = 0;
for (int i = 0; i < a.size(); i ++ )
{
sum1 *= 10;
sum1 += a[i];
}
for (int i = 0; i < b.size(); i ++ )
{
sum2 *= 10;
sum2 += b[i];
}
cout << sum1 + sum2 << endl;
return 0;
}
边栏推荐
- OpenGL Mosaic (8)
- Web site learning and sorting
- 軟件測試——接口常見問題匯總
- Leetcode- first unique character in string - simple
- Compilation croisée helloworld avec cmake
- ArrayList loop removes the pit encountered
- Integration of sentinel series Nacos to realize rule synchronization and persistence
- Leetcode- complement of numbers - simple
- Quartz basic use
- Solve the problem of garbled code in the MySQL execution SQL script database in docker (no need to rebuild the container)
猜你喜欢

OpenGL马赛克(八)

Interrupt processing

Use of Nacos configuration center

Experience of redis installation under Linux system (an error is reported at the same time. The struct redis server does not have a member named XXXX)

The reason why the process cannot be shut down after a spark job is executed and the solution

軟件測試——接口常見問題匯總

OpenGL Mosaic (8)

AUTOSAR实战教程pdf版

Validation set: ‘flowable-executable-process‘ | Problem: ‘flowable-servicetask-missing-implementatio

MongoDB 多字段聚合Group by
随机推荐
Leetcode- find all missing numbers in the array - simple
2021-9-19
Function and application scenario of field setaccessible() method
移动端适配方案
Leetcode- string addition - simple
Tongweb crawl performance log script
Etcd understanding of microservice architecture
The SQL file of mysql8.0 was imported into version 5.5. There was a pit
Initial redis experience
The problem of distinguishing and sharing sessions for multiple applications in tongweb
2 first experience of drools
Integration of sentinel series Nacos to realize rule synchronization and persistence
顶部下滑沉浸式dialog
Missing tag identification in cots RFID systems: bringing the gap between theory and Practice
18 flowable task manualtask and receivetask
Application virtual directory static resource configuration on tongweb
2021.9.29 learning log MIME type
Leetcode- longest palindrome string - simple
Leetcode perfect number simple
Leetcode fizz buzz simple