http://acm.hdu.edu.cn/showproblem.php?pid=1229
水题,我的代码:
#include<stdio.h>
bool judge(int a,int b,int k)
{
int i,c=1;
for(i=0;i<k;i++)
c*=10;
if(a%c==b%c)
return true;
return false;
}
int main()
{
int a,b,k;
while(scanf("%d%d%d",&a,&b,&k)!=EOF)
{
if(a==0 && b==0) break;
if(judge(a,b,k))
printf("-1/n");
else
printf("%d/n",a+b);
}
return 0;
}