#include <bits/stdc++.h>
using namespace std;
int main(){
int ip=0,iw,i,n,t,j,cc=1,d,a,b,c;
string x,y,z,x1,y1,z1;
cin >> x >> y >> z;
n=x.length();
for(i=0;i<n;++i){
for(j=i;j<n;++j){
x1=x.substr(i,j-i+1);
y1=y.substr(i,j-i+1);
z1=z.substr(i,j-i+1);
if(stoll(x1)+stoll(y1)==stoll(z1)){
++ip;
}
}
}
cout << ip;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <bits/stdc++.h> using namespace std; int main(){ int ip=0,iw,i,n,t,j,cc=1,d,a,b,c; string x,y,z,x1,y1,z1; cin >> x >> y >> z; n=x.length(); for(i=0;i<n;++i){ for(j=i;j<n;++j){ x1=x.substr(i,j-i+1); y1=y.substr(i,j-i+1); z1=z.substr(i,j-i+1); if(stoll(x1)+stoll(y1)==stoll(z1)){ ++ip; } } } cout << ip; return 0; } |
English