主旨:把字符串s1分成s11和s12,s2分成s21和s22,s11与s21相加,s12与s22相加, 后面的那部分相加后的结果如果比原来的长度长,则说明发生了进位, 就截取出来给前面的部分加上,然后再拼接到一起。

public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String ss1 = sc.nextLine();
            String ss2 = sc.nextLine();
            if(ss1.equals("0") && ss2.equals("0")){
                System.out.println(0);
                continue;
            }
            String s1 = ss1.length() > ss2.length()? ss2: ss1;
            String s2 = ss1.length() > ss2.length()? ss1: ss2;
            String s21 = s2.substring(0,s2.length()/2);
            String s22 = s2.substring(s2.length()/2);
            String s11 = "0";
            String s12 = s1;
            if(s1.length() - s22.length() <=0){ 
            }else{
                 s11 = s1.substring(0,s1.length() - s22.length());
                 s12 = s1.substring(s1.length() - s22.length());
            }
            
            long n11 = Long.parseLong(s11);
            long n12 = Long.parseLong(s12);
            long n21 = Long.parseLong(s21);
            long n22 = Long.parseLong(s22);
            long sum1 = n11 + n21;
            long sum2 = n12 + n22;
            String sm1 = String.valueOf(sum1);
            String sm2 = String.valueOf(sum2);
            if(sm2.length()>s22.length()){
                String pre = sm2.substring(0,1);
                String la = sm2.substring(1);
                Long pr = Long.parseLong(pre);
                sum1 +=pr;
                System.out.println(sum1 + la);
            }else{
                System.out.println(sm1+sm2);
            }
        }
    }
}