//判斷最後幾位是否相同即可 #includeint main() { int a,b,k; while(scanf("%d %d %d",&a,&b,&k)!=EOF){ if(a==0&&b==0) break; int m=a,n=b; int flag=0; while(k--){ int x=m%10; m/=10; int y=n%10; n/=10; if(x!=y){ flag=1; break; } } if(flag) printf("%d\n",a+b); else printf("-1\n"); } return 0; }