ICPC NEERC 2010 B - Binary Operation
View as PDFConsider a binary operation  defined on digits 
 to 
,
,
such that 
.
A binary operator  is a generalization of 
 to the set of non-negative
integers, 
.
The result of 
 is defined in the following
way: if one of the numbers 
 and 
 has fewer digits than the other
in decimal notation, then append leading zeroes to it, so that the
numbers are of the same length; then apply the operation 
 digit-wise to
the corresponding digits of 
 and 
.
Let us define  to be left-associative, that is, 
 is to
be interpreted as 
.
Given a binary operation  and two non-negative integers 
 and 
,
calculate the value of 
.
Input Specification
The first ten lines of the input contain the description of the binary
operation . The 
 line of the input contains a space-separated
list of ten digits - the 
 digit in this list is equal to 
.
The first digit in the first line is always .
The eleventh line of the input contains two non-negative integers 
and 
 
.
Output Specification
Output a single number - the value of
 without extra leading zeroes.
Sample Input
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 0
2 3 4 5 6 7 8 9 0 1
3 4 5 6 7 8 9 0 1 2
4 5 6 7 8 9 0 1 2 3
5 6 7 8 9 0 1 2 3 4
6 7 8 9 0 1 2 3 4 5
7 8 9 0 1 2 3 4 5 6
8 9 0 1 2 3 4 5 6 7
9 0 1 2 3 4 5 6 7 8
0 10
Sample Output
15
Comments