Total Submit: 2845 Accepted Submit: 764
a program that, given a natural number N between 0 and 4999 (inclusively), and M distinct decimal digits X1,X2..XM (at least one), finds the smallest strictly positive multiple of N that has no other digits besides X1,X2..XM (if such a multiple exists).
The input file has several data sets separated by an empty line, each data set having the following format:
On the first line - the number N
On the second line - the number M
On the following M lines - the digits X1,X2..XM.
For each data set, the program should write to standard output on a single line the multiple, if such a multiple exists, and 0 otherwise.
An example of input and output:
Input
22
3
7
0
1
2
1
1
Output
110
0
本文介绍了一种算法挑战,即给定一个自然数N(0到4999)及一组M个不同的十进制数字,寻找N的最小正整数倍数,该倍数仅由指定的数字组成。如果找不到这样的倍数,则输出0。文章还提供了一个输入输出示例。
316

被折叠的 条评论
为什么被折叠?



