### what is this mean?

Write 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). ????

nput

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.
Output

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.

 ``123456789101112131415`` ``````Sample Input 22 3 7 0 1 2 1 1 Sample Output 110 0``````

i dont understand why first answer is 110 and second one is 0
Last edited on
110 is multiple by 22 ( 22 * 5 = 110 ) and contains only digits from the set
{ 7, 0, 1 }
In the second case 0 means that there is no such a number that consists only from 1 and is multiple by 2.
can you explain digit set {7,0,1} part?

my english is not very good

is 0 mean first digit
1 second digit?
and 7 is 6th digit?

why 110 is the answer ?
 @codeback99 can you explain digit set {7,0,1} part?

 On the first line - the number N On the second line - the number M On the following M lines - the digits X1,X2...XM. Sample Input 22 3 7 0 1
Last edited on
I want to know how{7,0,1} is related with 110
Read my posts one more if one time is not enough.
Ok why 88 is not working with digit set {7,0,1}

can you explain this?
Number 98 contains neither digit from set { 7, 1, 0 }
first of all my understand of digit is

21 = 2(2th digit)1(1th digit)

and i dont understand what is 7th digit is related with 110

and other digit thig also

you are just repeating the question

I also understand the part until you wrote ....
Last edited on
Maybe somebody other will explain you. As for me then there was said enough that to understand the assignment.
thank you anyway
The digits in the set are not positions; {7, 0, 1} means a number with only using 7, 0, or 1 as a digit. Examples of this are 77, 0, 10, 700, 71, and of course 110. Example that do not work are 102 (has a 2, which is not in the set), 7713 (has a 3, which is not in the set), 56 (has a 5 and 6, neither of which are in the set).
Topic archived. No new replies allowed.