75A - Life Without Zeros - CodeForces Solution


implementation *1000

Please click on ads to support us..

Python Code:

a = ""
b = ""
a = input()
b = input()
a1 = int(a)
b1 = int(b)
c = a1 + b1
a = a.replace("0", "")
b = b.replace("0", "")
c = str(c)
c = c.replace("0", "")
d = int(a)
f = int(b)
c = int(c)
if (d+f) == c:
    print("YES")
else:
    print("NO")

C++ Code:

// AUTHOR - MALAY ZALAWADIA
// DATE - 28-01-2022
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define fl(i,n) for(ll i=0;i<n;i++)
#define fll(i,n,m) for(ll i=n;i<=m;i++)
#define rl(i,n,m) for(ll i=n;i>=m;i--)
#define py cout<<"YES"<< endl;
#define pn cout<<"NO"<< endl;
#define pi 3.141592653589793238
#define vr(v) v.begin(),v.end()
#define rv(v) v.end(),v.begin()
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define MMZ cout.tie(NULL);
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a/gcd(a,b)*b);}
string decToBinary(int n){string s="";int i = 0;while (n > 0) {s =to_string(n % 2)+s;n = n / 2;i++;}return s;}
ll binaryToDecimal(string n){string num = n;ll dec_value = 0;int base = 1;int len = num.length();for(int i = len - 1; i >= 0; i--){if (num[i] == '1')dec_value += base;base = base * 2;}return dec_value;}
bool isPrime(ll n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(int i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
bool nextPrime(ll N){if (N <= 1)return 2;ll prime = N;bool found = false;while (!found) {prime++;if (isPrime(prime)) found = true;}return prime;}
bool isPowerOfTwo(int n){if(n==0)return false;return (ceil(log2(n)) == floor(log2(n)));}
bool isPerfectSquare(ll x){if (x >= 0) {ll sr = sqrt(x);return (sr * sr == x);}return false;}
ll moduloMultiplication(ll a,ll b,ll mod){ll res = 0;a %= mod;while (b){if (b & 1)res = (res + a) % mod;b >>= 1;}return res;}
ll powermod(ll x, ll y, ll p){ll res = 1;x = x % p;if (x == 0) return 0;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}

int NoZero(ll n) {
    vector<ll> v;
    while(n) {
        if(n%10 == 0) {
            n /= 10;
        }
        else {
            v.pb(n%10);
            n /= 10;
        }
    }

    ll num = 0;
    rl(i,v.size() - 1,0) {
        num = num*10 + v[i];
    }

    return num;
}

int main() {
    Code By MMZ
    /*ll t;
    cin>>t;
    while(t--) {
      mmz();
    }*/
    //mmz();
    ll a,b;

    while(cin >> a >> b) {
        if(NoZero(a) + NoZero(b) == NoZero(a+b)) py
        else pn
    }
}


Comments

Submit
0 Comments
More Questions

80A - Panoramix's Prediction
1354B - Ternary String
122B - Lucky Substring
266B - Queue at the School
1490A - Dense Array
1650B - DIV + MOD
1549B - Gregor and the Pawn Game
553A - Kyoya and Colored Balls
1364A - XXXXX
1499B - Binary Removals
1569C - Jury Meeting
108A - Palindromic Times
46A - Ball Game
114A - Cifera
776A - A Serial Killer
25B - Phone numbers
1633C - Kill the Monster
1611A - Make Even
1030B - Vasya and Cornfield
1631A - Min Max Swap
1296B - Food Buying
133A - HQ9+
1650D - Twist the Permutation
1209A - Paint the Numbers
1234A - Equalize Prices Again
1613A - Long Comparison
1624B - Make AP
660B - Seating On Bus
405A - Gravity Flip
499B - Lecture