HDU 1230 mars A + bproblem description reads two positive integers A and B of Mars, and calculates a + B. It should be noted that on Mars, integers are not in single hexadecimal notation, And the nth hexadecimal notation is the nth prime number. For example, the 10 hexadecimal number 2 on the earth is counted as "1, 0" on Mars, because the single digit of Mars is 2 hexadecimal; the 10 hexadecimal number on the earth is 38, on Mars, it is recorded as ",", because the number of single digits of Mars is in hexadecimal notation, the number of digits is in hexadecimal notation, and the number of digits is in hexadecimal notation, the number of thousands is in the 7-digit format ......
Input test input contains several test cases. Each test case occupies one row and contains two positive integers A and B. The two adjacent double digits of the positive integers are separated by commas (,), and there is a space interval between A and B. When expression a or expression B is 0, the input ends, and the corresponding results are not output.
Output outputs one line for each test case, that is, the value of A + B in the Mars notation.
Sample input1, 0, 01, 6, 10 0
Sample output1, 0, AC Code As follows: # include <iostream>
Using namespace STD;
Int main ()
{
Int I, J;
Int A [] = {97,101 };
Char S1 [1000], S2 [1000];
Int N1 [30], N2 [30], Len, len1, len2, P, num, B, T;
While (CIN> S1> S2)
{
If (S1 [0] = '0' | S2 [0] = '0') break;
Memset (N1, 0, sizeof (N1 ));
Memset (N2, 0, sizeof (N2 ));
Len1 = strlen (S1 );
For (j = 0, I = len1-1; I> = 0; I --)
{
If (S1 [I] = ',' | I = 0)
{
If (I = 0) t = I;
Else t = I + 1;
Num = 0;
While (isdigit (S1 [T])
{
B = S1 [T]-'0 ';
Num = num * 10 + B;
T ++;
}
N1 [J ++] = num;
}
}
Len2 = strlen (S2 );
For (j = 0, I = len2-1; I> = 0; I --)
{
If (s2 [I] = ',' | I = 0)
{
If (I = 0) t = I;
Else t = I + 1;
Num = 0;
While (isdigit (s2 [T])
{
B = S2 [T]-'0 ';
Num = num * 10 + B;
T ++;
}
N2 [J ++] = num;
}
}
Len = len1> len2? Len1: len2;
For (P = I = 0; I <= Len + 1; I ++)
{
If (N1 [I] + N2 [I] + P> = A [I])
{
N1 [I] = N1 [I] + N2 [I] + P-A [I];
P = 1;
}
Else
{
N1 [I] = N1 [I] + N2 [I] + P;
P = 0;
}
}
P = 1;
For (I = 29; I> = 0; I --)
{
If (N1 [I] | P = 0)
{
Cout <N1 [I];
P = 0;
If (I)
Cout <',';
}
}
Cout <Endl;
}
Return 0;
}