1016

#include
#include
#include
#include

using namespace std;

long long result(long long num, unsigned n)
{
    string num_str = to_string(num);
    string n_str = to_string(n);
    string::size_type pos = 0;
    unsigned count = 0;
    while (pos!=string::npos)
    {
        pos = num_str.find(n_str, pos);
        if (pos != string::npos)
        {
            ++count;
            pos = pos + 1;
        }
    }

    long long ret = 0;
    while (count > 0)
    {
        if (ret == 0)
            ret = n;
        else
        {
            ret = ret * 10 + n;
        }
        --count;
    }
    return ret;
}

int main()
{
    long long a, b;
    unsigned m, n;
    cin >> a >> m >> b >> n;

    long long val_one = result(a, m);
    long long val_two = result(b, n);

    cout << (val_one + val_two);

    system("pause");
    return 0;
}

你可能感兴趣的:(1016)