1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main(){

    ios::sync_with_stdio(0);
    cin.tie(nullptr);

    string A, B, C;
    cin>>A>>B>>C;

    int ANS = 0;

    for(int s = 1; s <= A.length(); s++){

        for(int i = 0; i < A.length() - s + 1; i++){

            string sum;
            sum.resize(s);

            bool carry = 0;

            for(int j = i + s - 1; j >= i; j--){
                int tmp = A[j] + B[j] - 2 * '0' + carry;
                sum[j - i] = tmp % 10 + '0';
                carry = tmp / 10;
            }

            if(carry || C.substr(i, s) != sum)
                continue;

            ANS++;

        }

    }

    cout<<ANS;

   
    return 0;

}