#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
string a, b, c;
cin >> a >> b >> c;
int x = a.size();
int odp = 0;
for(int i=1;i<=x;i++)
{
for(int j=0;j+i-1<x;j++)
{
int czy = 1;
int carry = 0;
string d = "";
for(int h=j+i-1;h>=j;h--)
{
int z1 = a[h] - '0';
int z2 = b[h] - '0';
int wyn = c[h] - '0';
int sum = z1+z2+carry;
if(sum%10!=wyn)
{
czy = -1;
break;
}
else
{
carry=sum/10;
}
}
if(carry!=0) czy = -1;
if(czy==1) odp++;
}
}
cout << odp << '\n';
}
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 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string a, b, c; cin >> a >> b >> c; int x = a.size(); int odp = 0; for(int i=1;i<=x;i++) { for(int j=0;j+i-1<x;j++) { int czy = 1; int carry = 0; string d = ""; for(int h=j+i-1;h>=j;h--) { int z1 = a[h] - '0'; int z2 = b[h] - '0'; int wyn = c[h] - '0'; int sum = z1+z2+carry; if(sum%10!=wyn) { czy = -1; break; } else { carry=sum/10; } } if(carry!=0) czy = -1; if(czy==1) odp++; } } cout << odp << '\n'; } |
English