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
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int i, kon, poc;
    long long wyn=0;
    string a, b, c;
    cin>>a>>b>>c;
    vector<int>sumy(a.size(),0);
    for(i=0;i<a.size();i++){
        if(((int)a[i]-'0'+(int)b[i]-'0')%10==(int)c[i]-'0'){
            sumy[i]=1;
            wyn+=1;
        }else if(((int)a[i]-'0'+(int)b[i]-'0')%10+1==(int)c[i]-'0' && i!=0 && (int)a[i-1]-'0'+(int)b[i-1]-'0'>=10 ){
            sumy[i]=1;
        }
    }
    kon=0;
    poc=1;
    for(i=0;i<a.size()*2;i++){
        if(sumy[poc]==0 && poc!=a.size()-2){
            poc+=2;
            kon=poc-1;
            continue;
        }else if(sumy[kon]==0){
            kon++;
        }else if(sumy[poc]==1 && poc==a.size()-2){
            break;
        }else{
            wyn+=poc-kon;
            poc++;
        }
    }
    cout<<wyn+1<<'\n';
    return 0;
}