OddDigitable
SRM 255 · 2005-07-28 · by Andrew_Lazarev
SRM 255 · 2005-07-28 · by Andrew_Lazarev · Graph Theory, Math
Problem Statement
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.
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"
4)
2 0 Returns: "-1"
Submissions are judged against all 126 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class OddDigitable with a public method string findMultiple(int N, int M) · 126 test cases · 2 s / 256 MB per case