#P8708. [蓝桥杯 2020 省 A1] 整数小拼接

    ID: 9820 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>2020枚举双指针 two-pointer蓝桥杯省赛

[蓝桥杯 2020 省 A1] 整数小拼接

Problem Description

Given an array A1,A2,,AnA_1, A_2, \cdots, A_n of length nn. You can choose two numbers AiA_i and AjA_j (iji \neq j), then concatenate AiA_i and AjA_j in order to form a new integer. For example, 12 and 345 can be concatenated into 12345 or 34512. Note that swapping the order of AiA_i and AjA_j is always considered as 22 different ways, even when Ai=AjA_i = A_j.

Please calculate how many concatenations produce an integer that is less than or equal to KK.

Input Format

The first line contains 22 integers nn and KK.

The second line contains nn integers A1,A2,,AnA_1, A_2, \cdots, A_n.

Output Format

Output one integer representing the answer.

4 33
1 2 3 4
8

Hint

For 30%30\% of the test cases, 1n10001 \le n \le 1000, 1k1081 \le k \le 10^8, 1Ai1041 \le A_i \le 10^4.

For all test cases, 1n1051 \le n \le 10^5, 1k10101 \le k \le 10^{10}, 1Ai1091 \le A_i \le 10^9.

Lanqiao Cup 2020, first round of the provincial contest, Group A, Problem H.

Translated by ChatGPT 5