#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAXLEN 200
int substract (int *p1,int *p2,int len1,int len2)
{
int i;
if (LEN1<LEN2)
return-1;
if (LEN1==LEN2)
{
for (i=len1-1;i>=0;i--)
{
if (P1[i]>p2[i])
Break
else if (P1[i]<p2[i])
return-1;
}
}
for (i=0;i<=len1-1;i++)
{
P1[i]-=p2[i];
if (p1[i]<0)
{
p1[i]+=10;
p1[i+1]--;
}
}
for (i=len1-1;i>=0;i--)
if (P1[i])
return (I+1);
return 0;
}
int main ()
{
int n,k,i,j;
int len1,len2;
int ntimes;
int ntemp;
int Num_a[maxlen];
int Num_b[maxlen];
int Num_c[maxlen];
Char str1[maxlen+1];
Char str2[maxlen+1];
scanf ("%d", &n);
while (n--)
{
scanf ("%s", str1);
scanf ("%s", str2);
memset (num_a,0,sizeof (num_a));
memset (num_b,0,sizeof (Num_b));
memset (num_c,0,sizeof (Num_c));
Len1=strlen (STR1);
Len2=strlen (STR2);
for (j=0,i=len1-1;i>=0;j++,i--)
num_a[j]=str1[i]-' 0 ';
for (j=0,i=len2-1;i>=0;j++,i--)
num_b[j]=str2[i]-' 0 ';
if (LEN1<LEN2)
{
printf ("0\n");
Continue
}
Ntimes=len1-len2;
for (i=len1-1;i>=0;i--)
{
if (i>=ntimes)
Num_b[i]=num_b[i-ntimes];
Else
num_b[i]=0;
}
Len2=len1;
for (j=0;j<=ntimes;j++)
{
while ((Ntemp=substract (num_a,num_b+j,len1,len2-j)) >=0)
{
Len1=ntemp;
num_c[ntimes-j]++;
}
}
for (i=maxlen-1;num_c[i]==0&&i>=0;i--);
if (i>=0)
for (; i>=0;i--)
printf ("%d", num_c[i]);
Else
printf ("0");
printf ("\ n");
}
return 0;
}
Large number of divisions ... Hurry up, borrow the way of the ox people