#include <bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(0);
ios::sync_with_stdio(0);
int score = 0;
string liczba1;
string liczba2;
string liczba3;
cin >> liczba1;
cin >> liczba2;
cin >> liczba3;
string checkliczba1;
string checkliczba2;
string checkliczba3;
long long sus1;
long long sus2;
long long sus3;
for (int k = 0; k < liczba1.size(); k++)
{
for (int i = liczba1.size(); i > k; i--)
{
checkliczba1 = "";
checkliczba2 = "";
checkliczba3 = "";
for (int j = k; j < i; j++)
{
checkliczba1 = checkliczba1 + liczba1[j];
}
for (int j = k; j < i; j++)
{
checkliczba2 = checkliczba2 + liczba2[j];
}
for (int j = k; j < i; j++)
{
checkliczba3 = checkliczba3 + liczba3[j];
}
sus1 = stoll(checkliczba1);
sus2 = stoll(checkliczba2);
sus3 = stoll(checkliczba3);
if (sus1 + sus2 == sus3)
{
score++;
}
}
}
cout << score;
}
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 | #include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(0); int score = 0; string liczba1; string liczba2; string liczba3; cin >> liczba1; cin >> liczba2; cin >> liczba3; string checkliczba1; string checkliczba2; string checkliczba3; long long sus1; long long sus2; long long sus3; for (int k = 0; k < liczba1.size(); k++) { for (int i = liczba1.size(); i > k; i--) { checkliczba1 = ""; checkliczba2 = ""; checkliczba3 = ""; for (int j = k; j < i; j++) { checkliczba1 = checkliczba1 + liczba1[j]; } for (int j = k; j < i; j++) { checkliczba2 = checkliczba2 + liczba2[j]; } for (int j = k; j < i; j++) { checkliczba3 = checkliczba3 + liczba3[j]; } sus1 = stoll(checkliczba1); sus2 = stoll(checkliczba2); sus3 = stoll(checkliczba3); if (sus1 + sus2 == sus3) { score++; } } } cout << score; } |
English