正整数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 < 1010

输出格式:

在一行中输出PA + PB的值。

输入样例1:

3862767 6 13530293 3

输出样例1:

399

输入样例2:

3862767 1 13530293 8

输出样例2:

0
package com.wpr.demo2;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int da = scan.nextInt();
		int m=cal(a,da);
		a = scan.nextInt();
		da = scan.nextInt();
		System.out.print(m+cal(a,da));
	}
	static int cal(int a,int da){
		int m=0;
		while(a!=0){
			int temp = a%10;
			if(temp==da)
				m=m*10+da;
			a =a/10;
		}
		return m;
	}
}

1016. 部分A+B (15)的更多相关文章

  1. PAT乙级 1016. 部分A+B (15) C语言实现

    1016. 部分A+B (15) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 正整数A的“DA(为1位整数)部 ...

  2. PAT-乙级-1016. 部分A+B (15)

    1016. 部分A+B (15) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 正整数A的“DA(为1位整数)部 ...

  3. PAT (Basic Level) Practise (中文) 1016. 部分A+B (15)

    1016. 部分A+B (15) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 正整数A的"DA(为1 ...

  4. PAT乙级 1016. 部分A+B (15)

    题目传送:https://www.patest.cn/contests/pat-b-practise/1016 正整数A的“DA(为1位整数)部分”定义为由A中所有DA组成的新整数PA.例如:给定A ...

  5. PAT 1016. 部分A+B (15)

    正整数A的"DA(为1位整数)部分"定义为由A中所有DA组成的新整数PA.例如:给定A = 3862767,DA = 6,则A的"6部分"PA是66,因为A中有 ...

  6. PAT Basic 1016 部分A+B (15 分)

    正整数 A 的“D​A​​(为 1 位整数)部分”定义为由 A 中所有 D​A​​ 组成的新整数 P​A​​.例如:给定 8,D​A​​=6,则 A 的“6 部分”P​A​​ 是 66,因为 A 中有 ...

  7. PAT (Basic Level) Practice (中文)1016 部分A+B (15 分)

    正整数 A 的“D​A​​(为 1 位整数)部分”定义为由 A 中所有 D​A​​ 组成的新整数 P​A​​.例如:给定 8,D​A​​=6,则 A 的“6 部分”P​A​​ 是 66,因为 A 中有 ...

  8. 1016 部分A+B (15 分)

    正整数 A 的“D​A​​(为 1 位整数)部分”定义为由 A 中所有 D​A​​ 组成的新整数 P​A​​.例如:给定 8,D​A​​=6,则 A 的“6 部分”P​A​​ 是 66,因为 A 中有 ...

  9. PTA | 1016 部分A+B (15分)

    正整数 A 的"DA(为 1 位整数)部分"定义为由 A 中所有 DA 组成的新整数 PA.例如:给定 A=3862767,DA=6,则 A 的"6 部分"PA ...

随机推荐

  1. BZOJ 4690 Never Wait for Weights

    带权并查集23333333 注意dis[x]+=dis[fath[x]. #include<iostream> #include<cstdio> #include<cst ...

  2. HDU 5269 ZYB loves Xor I (二分法)

    题意: 给出一个序列,对每两个数求异或结果后取最低位的1出来作为一个数,然后求这些数字的和.比如:{a,b,c},结果是lowbit(a^b)+lowbit(a^c)+lowbit(b^a)+lowb ...

  3. 【C#学习笔记】改变字体

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  4. org.apache.jasper.JasperException: /WEB-INF/jsp/add.jsp(40,24) quote symbol expected

    add.jsp 的40行24列少了一个 引号

  5. win32 API 学习

    SendMessage 函数原型 LRESULT SendMessage(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM IParam) 详情:百度百科     msd ...

  6. java-No exception of type ConfigurationException can be thrown; an exception type must be a subclass of Throwable

    功能:读配置文件 java菜鸟:导入工程在报名处就开始报错,第一次遇到 import org.apache.commons.lang3.StringUtils; import org.apache.c ...

  7. NPOI 2.0导出word(docx格式)

    大名鼎鼎的NPOI用来导出EXCEL的文章园子里面有很多,可是用来导出WORD文档的文章大都含糊不清,最近刚好完成一个导出WORD文档的需求,在此分享下. NPOI里面认为word文档的最基本的结构是 ...

  8. UE删除空行

  9. 使用Spring 3的@value简化配置文件的读取

    Spring 3支持@value注解的方式获取properties文件中的配置值,大简化了读取配置文件的代码. 1.在applicationContext.xml文件中配置properties文件 & ...

  10. ArcEngine 通过SpatialRelDescription删除不相交要素

    ISpatialFilter.SpatialRel设置为esriSpatialRelRelate,并且设置SpatialRelDescription为某个字符串.该字符串的构造方法:该字符串为长度为9 ...