Code Festival D Compress numbers by Naoaki

i,k;char a[11],A[11],b[11];main(j){m:while(~scanf("%s\n",A)){gets(b);for(i=0;i<1024;i++){strcpy(a,A);for(k=j=strlen(a)-1;j;j--)(i>>j)%2?a[j-1]=(a[j-1]+a[j]-96)%10+48,memmove(a+j,a+j+1,k-j+1):0;if(!strcmp(a,b)){puts("YES");goto m;}}puts("NO");}}




Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page