#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
string a,b,c;
cin>>a>>b>>c;
int n=a.size(),p=2,q=0;
long long z=0;
for(int i=0;i<n;i++){
int s=a[i]+b[i]-96,d=s-(c[i]-'0'),r,o;
if(d==0)r=0,o=0;
else if(d==10)r=0,o=1;
else if(d==-1)r=1,o=0;
else if(d==9)r=1,o=1;
else{
q=0;
p=2;
continue;
}
if(p<2&&o!=p)q=0;
if(!o)q++;
if(!r)z+=q;
p=r;
}
cout<<z<<'\n';
return 0;
}
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 | #include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); string a,b,c; cin>>a>>b>>c; int n=a.size(),p=2,q=0; long long z=0; for(int i=0;i<n;i++){ int s=a[i]+b[i]-96,d=s-(c[i]-'0'),r,o; if(d==0)r=0,o=0; else if(d==10)r=0,o=1; else if(d==-1)r=1,o=0; else if(d==9)r=1,o=1; else{ q=0; p=2; continue; } if(p<2&&o!=p)q=0; if(!o)q++; if(!r)z+=q; p=r; } cout<<z<<'\n'; return 0; } |
English