Not quite understand,but amazing。。。。
1 #include <cstdio>
2 #include <iostream>
3 #include <cstring>
4 using namespace std;
5
6 int l;
7
8 int work(int o,char *O,int I)
9 {
10 char c,*D = O;
11 if (o > 0)
12 {
13 for(l = 0; D[l]; D[l++] -= 10)
14 {
15 D[l++] -= 120;
16 D[l] -= 110;
17 while (!work(0,O,l))
18 D[l] += 20;
19 putchar((D[l]+1032)/20) ;
20 }
21 putchar(10);
22 }
23 else
24 {
25 c = o+(D[I]+82)%10-(I>l/2)*(D[I-l+I]+72)/10-9;
26 D[I] += (I < 0)?0:!(o = work(c/10,O,I-1))*((c+999)%10-(D[I]+92)%10);
27 }
28 return o;
29 }
30
31 int main()
32 {
33 char s[1200];
34 s[0] = '0';
35 scanf("%s",s+1);
36 if(strlen(s)%2 == 1) work(2,s+1,0);
37 else work(2,s,0);
38 return 0;
39 }
2 #include <iostream>
3 #include <cstring>
4 using namespace std;
5
6 int l;
7
8 int work(int o,char *O,int I)
9 {
10 char c,*D = O;
11 if (o > 0)
12 {
13 for(l = 0; D[l]; D[l++] -= 10)
14 {
15 D[l++] -= 120;
16 D[l] -= 110;
17 while (!work(0,O,l))
18 D[l] += 20;
19 putchar((D[l]+1032)/20) ;
20 }
21 putchar(10);
22 }
23 else
24 {
25 c = o+(D[I]+82)%10-(I>l/2)*(D[I-l+I]+72)/10-9;
26 D[I] += (I < 0)?0:!(o = work(c/10,O,I-1))*((c+999)%10-(D[I]+92)%10);
27 }
28 return o;
29 }
30
31 int main()
32 {
33 char s[1200];
34 s[0] = '0';
35 scanf("%s",s+1);
36 if(strlen(s)%2 == 1) work(2,s+1,0);
37 else work(2,s,0);
38 return 0;
39 }