#include<stdio.h>
long int an(long int n)
{
long int r = 0, sum = 0;
while(n != 0)
{
r = n%10;
sum = sum *10 + r;
n = n/10;
}
return sum;
}
int main()
{
long int n, p, q, i;
while(scanf("%ld", &n) != EOF)
{
for(i=0; i<n; i++)
{
scanf("%ld", &p);
q = 0;
while(p != an(p))
{
p = p + an(p);
q++;
if(q >= 1000)
break;
}
printf("%ld %ld\n", q, p);
}
}
return 0;
}
long int an(long int n)
{
long int r = 0, sum = 0;
while(n != 0)
{
r = n%10;
sum = sum *10 + r;
n = n/10;
}
return sum;
}
int main()
{
long int n, p, q, i;
while(scanf("%ld", &n) != EOF)
{
for(i=0; i<n; i++)
{
scanf("%ld", &p);
q = 0;
while(p != an(p))
{
p = p + an(p);
q++;
if(q >= 1000)
break;
}
printf("%ld %ld\n", q, p);
}
}
return 0;
}
Comments
Post a Comment