TopcoderArchiveVisit Topcoder
SRM28 Jul 2005
SRM 255

OddDigitable

Problem statement, definition, constraints, and public examples.

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

  1. 10
    7
    Returns: "7"
  2. 22
    12
    Returns: "-1"
  3. 29
    0
    Returns: "319"
  4. 5934
    2735
    Returns: "791957"
Back to all problems