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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#define N 1000000
using namespace std;
int S[2][N];
int R[2][N];
int main() {
    int count = 0;
    string A, B, C;
    cin>>A>>B>>C;
    int n = A.size();
    for(int i=0; i<n; i++){
        int a = A[i];
        S[0][i] = (a - '0');
        S[1][i] = (a - '0');
    }
    for(int i=0; i<n; i++){
        int b = B[i];
        S[0][i] += (b - '0');
        S[1][i] += (b - '0');
    }
    for(int i=0; i<n; i++){
        int c = C[i];
        R[0][i] = (c - '0');
        R[1][i] = (c - '0');
        if(S[0][i]==R[0][i]) count++;
    }
    
    /*for(int i=0; i<n; i++){
        cout<<S[i][0]<<" ";
    }
    cout<<endl;
    for(int i=0; i<n; i++){
        cout<<C[i]<<" ";
    }
    cout<<endl;*/
    int mult = 10;
    
    for(int i=1; i<=n; i++){
        for(int j=0; j < n - i; j++){
            S[1][j] = mult*S[0][j] + S[1][j+1];
            R[1][j] = mult*R[0][j] + R[1][j+1];
            //cout<<"C = "<<C[j]<<endl;
            //cout<<S[1][j]<<" = "<<mult<<"*"<<S[0][j]<<"+"<<S[1][j+1]<<endl;
            //cout<<1<<","<<j<<" = "<<mult<<" * "<<0<<","<<j<<" + "<<1<<","<<j+1<<endl;
            if(R[1][j]==S[1][j]) count++;
        }
        
        /*for(int j=0; j<n; j++){
            cout<<S[1][j]<<" ";
        }
        cout<<endl;
        
        for(int j=0; j<n; j++){
            cout<<R[1][j]<<" ";
        }
        cout<<endl;*/
        mult*=10;

    }
    /*for(int i=0; i<=n; i++){
        for(int j=0; j<n-i; j++){
            cout<<S[i][j]<<" ";
        }
        cout<<endl;
    }

    for(int i=0; i<=n; i++){
        for(int j=0; j<n-i; j++){
            cout<<R[i][j]<<" ";
        }
        cout<<endl;
    }*/
    
    cout<<count;
    
    return 0;
}