当前位置:网站首页>1016 部分A+B
1016 部分A+B
2022-06-29 04:09:00 【乐乐~LL】
正整数 A 的“DA(为 1 位整数)部分”定义为由 A 中所有 DA 组成的新整数 PA。例如:给定 A=3862767,DA=6,则 A 的“6 部分”PA 是 66,因为 A 中有 2 个 6。
现给定 A、DA、B、DB,请编写程序计算 PA+PB。
输入格式:
输入在一行中依次给出 A、DA、B、DB,中间以空格分隔,其中 0<A,B<109。
输出格式:
在一行中输出 PA+PB 的值。
输入样例 1:
3862767 6 13530293 3
输出样例 1:
399
输入样例 2:
3862767 1 13530293 8
输出样例 2:
0代码如下:
#include<stdio.h>
int main()
{
int a, a1, b, b1,i,k1=0,k2=0,j;
scanf("%d %d %d %d", &a, &a1, &b, &b1);
int ma = 0, mb = 0;//求和
for (i = 0; a > 0; a /= 10)
if (a % 10 == a1)
k1++;
for (i = 0; b > 0; b /= 10)
if (b % 10 == b1)
k2++;
for (j = 0; j < k1; j++)
ma = ma * 10 + a1;
for (j = 0; j < k2; j++)
mb = mb * 10 + b1;
printf("%d", ma + mb);
return 0;
}边栏推荐
- Tech Cloud Report: Mixed Office B side: How Safety and Efficiency can be combined?
- MySQL column to row conversion without Union
- 女程序员晒出5月的工资条:工资是高,但是真累,网友评论炸锅了
- 你为什么做测试/开发程序员?还能回想出来吗......
- New listing of operation light 3.0 -- a sincere work of self subversion across the times
- If you choose the right school, you can enter Huawei as a junior college. I wish I had known
- [fpga+sin] FPGA implementation of sinusoidal signal generator module based on DDS (direct digital synthesis)
- 情绪的变化需要控制
- Implementation of thread pool based on variable parameter template
- Logstash starts too slowly or even gets stuck
猜你喜欢

Apifox : 不仅是Api调试工具,更是开发团队的协作神器
![[filter design] customize the filter with MATLAB according to the design index](/img/b2/b5576c5eb6dbe9a0c64158802aa1d0.png)
[filter design] customize the filter with MATLAB according to the design index

MobileOne: 移动端仅需1ms的高性能骨干

基于可变参模板实现的线程池

Libuv library overview and comparison of libevent, libev and libuv (Reprint)

SEAttention 通道注意力機制

自己动手搭建一个简单的网站

【FPGA+sin】基于DDS(直接数字合成)的正弦信号发生器模块FPGA实现

IDEA修改jvm内存

数据库和缓存如何保持一致性
随机推荐
sql两列变为多行过滤显示
Kingbase export table structure
开发者方案 · 环境监测设备(小熊派物联网开发板)接入涂鸦IoT开发平台
On June 27, 2022, I have the right to choose the journey of the summer vacation.
NotImplementedError: Could not run torchvision::nms
How to back up all data on Apple mobile phone in 2 steps (free)
请问大佬,Oracle CDC报错 Call snapshotState on closed sou
SQL two columns become multi row filter display
【FPGA数学公式】使用FPGA实现常用数学公式
欧拉开源社区第二届理事会第二次会议召开,新华三、超聚变和龙芯中科成为理事会成员单位
[WC2021] 斐波那契——数论、斐波那契数列
Data collection and management [5]
Black screen and error reporting when loading custom models for gazebo with roslaunch
SEAttention 通道注意力机制
Emotional changes need to be controlled
增额终身寿险下架了吗?现在还有哪些增额终身寿险产品?
Binary tree serialization and deserialization (leetcode (difficult))
【C语言】详解线程回收函数 pthread_join
MobileOne: 移动端仅需1ms的高性能骨干
Data collection and management [9]