#abc287b. B - Postal Card
B - Postal Card
Score : points
问题描述
给定 个长度为六的数字字符串,记第 ()个字符串为 。
另外还给定 个长度为三的数字字符串,记第 ()个字符串为 。
请找出在 中有多少个字符串的最后三个字符与 中的一个或多个字符串完全相同。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given strings of length six each, consisting of digits. Let be the -th of them.
You are also given strings of length three each, consisting of digits. Let be the -th of them.
Find the number of strings among whose last three characters coincide with one or more of .
Constraints
- and are integers.
- is a string of length consisting of digits, for all .
- is a string of length consisting of digits, for all .
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 3
142857
004159
071028
159
287
857
Sample Output 1
2
The last three characters of are 857
, which coincide with .
The last three characters of are 159
, which coincide with .
The last three characters of are 028
, which do not coincide with , , or .
Thus, the answer is .
Sample Input 2
5 4
235983
109467
823476
592801
000333
333
108
467
983
Sample Output 2
3
Sample Input 3
4 4
000000
123456
987111
000000
000
111
999
111
Sample Output 3
3
update @ 2024/3/10 11:59:25