UberOA #10
Spy Access Code Fragments
估计中等可在线判题
Count the ordered pairs of distinct indices (i,j) such that concatenating the canonical decimal representations of the two positive integers, in that order, gives exactly accessCode. Different indices holding the same value are still different choices.
This site's standard input/output is stated explicitly.
输入格式
The first line contains n, the second line contains n positive integers fragments, and the third line contains the positive integer accessCode. 2≤n≤30000, 1≤fragments[i]≤10⁹. The source places no upper bound on the target; on this site the target is a positive integer with at most 20 digits, since more than 20 digits cannot be formed from two valid fragments.
输出格式
Output one integer answer.
样例 1
输入:
5
12 12 13 12 12
1212
输出:
12
样例 2
输入:
4
22 8 22 110
1108
输出:
1
样例 3
输入:
5
777 7 777 77 77
7777
输出:
6
样例说明
Example 1: choosing different indices among four 12s gives 4×3=12 pairs. Example 2: only 110 followed by 8 works, 1 pair. Example 3: 777 followed by 7 gives 2 pairs, 7 followed by 777 gives 2 pairs, and the two 77s concatenated with each other give 2 pairs, 6 in total.