J. Ugly Problem
Test instructions: Divide the large number into a palindrome number of no more than 50
The main point: each time with no more than the large number of palindrome to reduce, the results to be carried out again, note "10" The number of pit points
#include <iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<string>#include<cstdlib>#include<vector>#include<Set>#include<map>using namespacestd;Const Doubleeps=1e-8;intLen;voidSubtractChar*a,Char*b,Char*c) { for(inti=len-1; i>=0; i--) {C[i]=a[i]-b[i]+'0'; if(c[i]<'0') c[i]+=Ten, a[i-1]--; }}Charstr[2][1005],sub[ -][1005];intMain () {intI,j,k,n; scanf ("%d",&n); GetChar (); for(intH=1; h<=n;h++) {memset (sub,'0',sizeof(sub)); Gets (str[0]); Len=strlen (str[0]); intOld=1, now=0; intCnt=0; for(i=0; Str[now][i];) { old^=1, now^=1; if(!STRCMP (Str[old]+i,"Ten") ) {sub[cnt][0]='9'; sub[cnt][1]=0; cnt++; sub[cnt][0]='1'; sub[cnt][1]=0; cnt++; Break; } for(j=i;j<=len-1-j+i && str[old][j]<=str[old][len-1-j+i];j++); strcpy (Sub[cnt],str[old]); if(j<len-1-j+i) {sub[cnt][(i+len-1)/2]--; for(J= (i+len-1)/2; j>=0&& sub[cnt][j]<'0'; j--) sub[cnt][j]+=Ten, sub[cnt][j-1]--; } for(j=0; sub[cnt][j]=='0'; j + +); for(k=j;k<=len-1-k+j;k++) sub[cnt][len-1-k+j]=Sub[cnt][k]; Sub[cnt][len]=0; Subtract (Str[old],sub[cnt],str[now]); for(; str[now][i]=='0'; i++); CNT++; } printf ("Case #%d:\n%d\n", h,cnt); for(i=0; i<cnt;i++) { Char*s; for(s=sub[i];*s=='0'; s++); Puts (s); } } return 0;}
J Ugly Problem
2016 Chinese college Student Program Design Competition (Changchun)-Re-entry of the game