# [Solution] Integer concatenation solution codechef

## Integer concatenation solution codechef

Concatenation of two integers is obtained as follows: First, convert both integers to strings. Then concatenate both strings into one and convert this concatenated string back to integer.

For example, concatenation of 6 and 7 is CONC(6,7)=67, concatenation of 123 and 45 is CONC(123,45)=12345.

You are given an array A consisting of N integers. You are also given two integers L and R. Find the number of pairs (i, j) such that 1i,jN and LCONC(Ai,Aj)R

Note: Since the size of the input and output is large, please use fast input-output methods.

### Integer concatenation solution codechef Input Format

• The first line will contain T, the number of test cases. Then T test cases follow.
• The first line of each test case contains three integers N,L,R.
• The second line of each test case line contains N integers A1,A2,,AN.

### Integer concatenation solution codechef Output Format

For each testcase, output in a single line the number of suitable pairs.

### Constraints

• 1T104
• 1N105
• 1LR1015
• 1Ai107
• Sum of N over all test cases does not exceed 106.

### Integer concatenation solution codechef Sample Input 1

4
2 10 52
2 5
3 58 100
4 2 3
4 100 1000
1 10 100 1000
5 28 102
3 2 1 9 10


### Integer concatenation solution codechef Sample Output 1

3
0
2
11


### Explanation

Test case 1:

• (i=1,j=1): CONC(A1,A1)=22 and 102252.

• (i=1,j=2): CONC(A1,A2)=25 and 102552.

• (i=2,j=1): CONC(A2,A1)=52 and 105252.

• (i=2,j=2): CONC(A2,A2)=55 and 1055 but 5552.

So there are three suitable pairs.

Test case 2: There is no suitable pair.

Test case 3: The suitable pairs are (2,1) and (1,2).

Updating Soon… Counting Tuples codechef solution