73 lines
1.7 KiB
C++
73 lines
1.7 KiB
C++
#include <cstring>
|
|
#include <iostream>
|
|
using namespace std;
|
|
int pan = 0, ans[11][10] = { 0 }, ce[11] = { 0 };
|
|
void doit(int n[], int big)
|
|
{
|
|
pan++;
|
|
ce[pan] = big;
|
|
if (pan == 11) {
|
|
cout << "NO";
|
|
return;
|
|
}
|
|
for (int i = 0; i < ce[pan]; i++) {
|
|
ans[pan][i] += n[i] + n[ce[pan] - i - 1];
|
|
ans[pan][i + 1] = ans[pan][i] / 10;
|
|
ans[pan][i] %= 10;
|
|
}
|
|
if (ans[pan][ce[pan]] != 0) {
|
|
ce[pan]++;
|
|
}
|
|
/*
|
|
for(int i=0;i<ce[pan];i++){
|
|
cout<<n[i];
|
|
}
|
|
cout<<"+";
|
|
for(int i=ce[pan]-1;i>=0;i--){
|
|
cout<<n[i];
|
|
}
|
|
if(ans[pan][ce[pan]]!=0){
|
|
ce[pan]++;
|
|
}
|
|
cout<<"=";
|
|
for(int i=ce[pan]-1;i>=0;i--){
|
|
cout<<ans[pan][i];
|
|
}
|
|
cout<<endl;*/
|
|
for (int i = 0; i < ce[pan] / 2; i++) {
|
|
if (ans[pan][i] != ans[pan][ce[pan] - i - 1]) {
|
|
//cout<<pan<<endl;
|
|
doit(ans[pan], ce[pan]);
|
|
return;
|
|
}
|
|
}
|
|
for (int i = 1; i <= pan; i++) {
|
|
for (int j = ce[i-1] - 1; j >= 0; j--) {
|
|
cout << ans[i-1][j];
|
|
}
|
|
cout << "+";
|
|
bool u=0;
|
|
for (int j = 0; j < ce[i-1]; j++) {
|
|
if(u!=0||ans[i-1][j]!=0){
|
|
cout << ans[i-1][j];
|
|
u=1;
|
|
}
|
|
}
|
|
cout << "=";
|
|
for (int j = ce[i] - 1; j >= 0; j--) {
|
|
cout << ans[i][j];
|
|
}
|
|
cout << endl;
|
|
}
|
|
}
|
|
int main()
|
|
{
|
|
string n;
|
|
cin >> n;
|
|
ce[0]=n.size();
|
|
for (int i = 0; i < ce[0]; i++) {
|
|
ans[0][ce[0]-i-1] = n[i] - '0';
|
|
}
|
|
doit(ans[0], ce[0]);
|
|
}
|