#include<stdio.h>
#include<iostream>
using namespace std;
bool Judge(int num1,int num2,int k)
{
if(k == 0)
return false;
for(int i=1;i<=k;i++)
{
if((num1%10) != (num2%10))
return false;
num1/=10;
num2/=10;
}
return true;
}
int main()
{
int num1,num2,k;
while(scanf("%d %d %d",&num1,&num2,&k),num1,num2)
{
if(Judge(num1,num2,k))
printf("-1\n");
else
printf("%d\n",num1+num2);
}
return 0;
}
时间: 2024-10-16 00:23:47