TopCoder problem "OddDigitable" used in SRM 255 (Division I Level Three)



Problem Statement

    

An odd-digitable number is a positive integer which consists of only odd digits. For example, 1, 7, 15, 91 and 73353 are odd-digitable numbers, but 2, 70, 94 and 72653 are not odd-digitable.

You will be given integers N and M. Your method should return the smallest odd-digitable number that equals M modulo N. Your method should return "-1"(quotes for clarity only) if there are no such odd-digitable numbers.

 

Definition

    
Class:OddDigitable
Method:findMultiple
Parameters:int, int
Returns:String
Method signature:String findMultiple(int N, int M)
(be sure your method is public)
    
 

Constraints

-N will be between 2 and 100000, inclusive.
-M will be between 0 and N-1, inclusive.
 

Examples

0)
    
10
7
Returns: "7"
1)
    
22
12
Returns: "-1"
2)
    
29
0
Returns: "319"
3)
    
5934
2735
Returns: "791957"

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=4527

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=7228&pm=4527

Writer:

Andrew_Lazarev

Testers:

PabloGilberto , lbackstrom , brett1479

Problem categories:

Graph Theory, Math