• 欢迎光临~

## Code:

``````#include<bits/stdc++.h>
#define ll long long
#define linf 0x3f3f3f3f3f3f3f3f
#define inf 0x7fffffff
#define v e[i].y
using namespace std;
char ch=getchar();ll x=0,w=1;
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9')x=x*10+ch-48,ch=getchar();return x*w;
}
inline void write(ll x){
if(x<0)x=-x,putchar('-');
if(x<10){putchar(48+x);return;}
write(x/10),putchar((x+10)%10+48);
}
bool dp[25][25];
bool dfs(int x,int y){//x:c,y:a
if(x==ct)return y>=at?1:(dp[x][y]=0);
if(dp[x][y]==0)return 0;
if(cc[x+1]-aa[y+1]>=0&&cc[x+1]-aa[y+1]<10){
ans[++t]=cc[x+1]-aa[y+1];
if(dp[x+1][y+1]=dfs(x+1,y+1))return 1;
t--;
}
if(x<=ct-2&&cc[x+2]!=0&&cc[x+2]*10+cc[x+1]-aa[y+1]>=0&&cc[x+2]*10+cc[x+1]-aa[y+1]<10){
ans[++t]=cc[x+2]*10+cc[x+1]-aa[y+1];
if(dp[x+2][y+1]=dfs(x+2,y+1))return 1;
t--;
}
return dp[x][y]=0;
}
int main(){
while(T--){
memset(aa,0,sizeof(aa));
memset(cc,0,sizeof(cc));
for(int i=0;i<=23;i++)for(int j=0;j<=23;j++)dp[i][j]=1;
while(a)aa[++at]=(a+10)%10,a/=10;
while(c)cc[++ct]=(c+10)%10,c/=10;
if(dfs(0,0)){
while(t&&ans[t]==0)t--;
if(t==0)ans[++t]=0;
for(int i=t;i>=1;i--)putchar(ans[i]+48);
}
else printf("-1");
putchar('n');
}
return 0;
}
``````