Friday, 23 October 2015

Codeforces Gym 100796A - AHB Problem_Solution

/*
Tanzila Islam
Southeast University
mail : tanzilamohita@gmail.com
Problem Link : http://codeforces.com/gym/100796/problem/A
*/
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>

using namespace std;

int main() {
    string a, b;
    long long int ans[100];
    while(cin >> a >> b){
        if(a.size() != b.size())
            break;
        else if(a==b) cout << "0" << endl;

        bool flag = false;
        for(int i=0; i<a.size(); i++) {
            ans[i]=abs((a[i]-48)-(b[i]-48));
            if (ans[i] > 0) flag = true;
            if (flag) cout << ans[i];
        }
        cout << endl;
    }
    return 0;
}

No comments:

Post a Comment