# Include <iostream. h>
# Include <string. h>
# Include <math. h>
# Include <iomanip. h>
Char s [100];
Char chu [2, 1000] [100];
// Because Chu is output each time, if Chu is used again
// If there is no elimination, there is a problem, so a 1000-Bit String Array is enabled, but this is better
// The image does not solve the actual problem ......
Int main ()
{
Long from, to, A, I, J, K, temp, sum, jishu = 0;
While (CIN> S> from> )! = NULL)
{
Sum = 0;
K = strlen (s );
For (I = 0; I <K; I ++)
{
If (s [I]> '9 ')
A = s [I]-'A' + 10;
Else
A = s [I]-'0 ';
Sum + = POW (from, k-i-1) *;
}
If (! = 10)
{
J = 0;
While (sum! = 0)
{
If (sum % to> = 10)
Chu [jishu] [J] = sum % to-10 + 'a ';
Else
Chu [jishu] [J] = sum % to + '0 ';
Sum/=;
J ++;
}
For (I = 0; I <j/2; I ++)
{
Temp = chu [jishu] [I];
Chu [jishu] [I] = chu [jishu] [j-i-1];
Chu [jishu] [j-i-1] = temp;
}
If (strlen (chu [jishu]) <= 7)
Cout <setiosflags (IOs: Right) <SETW (7) <chu [jishu] <Endl;
Else
Cout <setiosflags (IOs: Right) <SETW (7) <"error" <Endl;
}
Else
{
If (sum/10000000 = 0)
Cout <setiosflags (IOs: Right) <SETW (7) <sum <Endl;
Else
Cout <setiosflags (IOs: Right) <SETW (7) <"error" <Endl;
}
Jishu ++;
}
Return 0;
}