CodeForces-75A

CodeForces-75A

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.next();
            String ss = sc.next();
            int a = Integer.parseInt(s);
            int b = Integer.parseInt(ss);
            int ab = a+b;
            String aabb = ""+ab;
            char[] s1 = new char[100000];
            char[] ss1 = new char[100000];
            char[] ab1 = new char[100000];
            int cnt1 = 0;
            for (int i = 0; i < s.length(); i++) {
                if(s.charAt(i) != '0'){
                    s1[cnt1] = s.charAt(i);
                    cnt1++;
                }
            }
            int cnt2 = 0;
            for (int i = 0; i < ss.length(); i++) {
                if(ss.charAt(i) != '0'){
                    ss1[cnt2] = ss.charAt(i);
                    cnt2++;
                }
            }
            int cnt3 = 0;
            for (int i = 0; i < aabb.length(); i++) {
                if(aabb.charAt(i) != '0'){
                    ab1[cnt3] = aabb.charAt(i);
                    cnt3++;
                }
            }
            String str1 = new String(s1);
            String str2 = new String(ss1);
            String str3 = new String(ab1);
            int c = Integer.parseInt(str1.trim());
            int d = Integer.parseInt(str2.trim());
            int aaabbb = Integer.parseInt(str3.trim());
            int cd = c + d;
            if(aaabbb == cd) System.out.println("YES");
            else System.out.println("NO");
        }
    }
}
上一篇:LeetCode-205-同构字符串


下一篇:LeetCode第276场周赛题解