题解:
有字符串 和 数学运算 这两种比较快写的办法
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
long s1,s2,c1,c2;
s1=sc.nextLong();
c1=sc.nextLong();
s2=sc.nextLong();
c2=sc.nextLong();
long pa=0,pb=0;
while (s1>0){
if (s1%10==c1)
pa=pa*10+c1;
s1/=10;
}
while (s2>0){
if (s2%10==c2)
pb=pb*10+c2;
s2/=10;
}
System.out.println(pa+pb);
}
}