AtCoder Beginner Contest 423
翻译中…
Problem Statement
翻译中…
Find the minimum possible value of a positive integer $n$ that satisfies the following two conditions:
翻译中…
$n$is a multiple of$K$.- The decimal representation of
$n$contains$S$as a substring.
翻译中…
$T$ test cases are given, so find the answer for each.
翻译中…
What is a substring? A substring of a string $S$ is a string obtained by deleting zero or more characters from the beginning and zero or more characters from the end of $S$. For example, ab and b are substrings of abc, but ac and cba are not substrings of abc.
翻译中…
Constraints
翻译中…
$T$is an integer.$1 \leq T \leq 200$$K$is an integer.$1 \leq K \leq 10^9$$S$is a string consisting of digits (0-9).- The first character of
$S$is not0. $1 \leq |S| \leq 5 \times 10^5$- For each input file, the sum of
$|S|$over all test cases is at most$5 \times 10^5$.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
T
\textrm{case}_1
\textrm{case}_2
\vdots
\textrm{case}_T
翻译中…
$\textrm{case}_i$ represents the $i$-th test case. Each test case is given in the following format:
翻译中…
K
S
翻译中…
Output
翻译中…
Output $T$ lines. The $i$-th line ($1 \leq i \leq T$) should contain the answer to the $i$-th test case.
翻译中…
样例
Input #1
4
271
414
15
23
155521
1000
920950937
999999999999999999999
Output #1
34146
1230
100000003
1000000999999999999999999999
In the first test case, among positive integers that are multiples of $271$, the minimum one whose decimal representation contains `414` as a substring is $34146$.
In the second test case, among positive integers that are multiples of $15$, the minimum one whose decimal representation contains `23` as a substring is $1230$.
In the third test case, among positive integers that are multiples of $155521$, the minimum one whose decimal representation contains `1000` as a substring is $100000003$.
In the fourth test case, among positive integers that are multiples of $920950937$, the minimum one whose decimal representation contains `999999999999999999999` as a substring is $1000000999999999999999999999$.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。