|
||||||||||
Yet Another Multiple ProblemTime Limit: 40000/20000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 7655 Accepted Submission(s): 1882 Problem Description There are tons of problems about integer multiples. Despite the fact that the topic is not original, the content is highly challenging. That¡¯s why we call it ¡°Yet Another Multiple Problem¡±. In this problem, you¡¯re asked to solve the following question: Given a positive integer n and m decimal digits, what is the minimal positive multiple of n whose decimal notation does not contain any of the given digits? Input There are several test cases. For each test case, there are two lines. The first line contains two integers n and m (1 ¡Ü n ¡Ü 104). The second line contains m decimal digits separated by spaces. Input is terminated by EOF. Output For each test case, output one line ¡°Case X: Y¡± where X is the test case number (starting from 1) while Y is the minimal multiple satisfying the above-mentioned conditions or ¡°-1¡± (without quotation marks) in case there does not exist such a multiple. Sample Input
Sample Output
Source | ||||||||||
|