TopcoderArchiveVisit Topcoder
SRM20 May 2017
SRM 716

Permutiple

Problem statement, definition, constraints, and public examples.

Problem Statement

You are given a positive integer x. Please check whether we can rearrange the digits of x (in base 10, without leading zeros) to produce a different number that is a multiple of x.

Return "Possible" if this can be done and "Impossible" otherwise. Note that the return value is case-sensitive.

Definition

Class:
Permutiple
Method:
isPossible
Parameters:
int
Returns:
String
Method signature:
String isPossible(int x)
(be sure your method is public)

Constraints

  • x will be between 1 and 1,000,000, inclusive.

Examples

  1. 142857
    Returns: "Possible"
    One valid way of rearranging the digits of 142857 is to form the number 285714. This new number is a multiple of x: we have 285714 = 2 * 142857. Another valid way is to form the number 857142 (which is equal to 6 * 142857).
  2. 14
    Returns: "Impossible"
    The only other number we can get by rearranging the digits of the number 14 is the number 41. As 41 is not a multiple of 14, there is no solution.
  3. 1035
    Returns: "Possible"
    We can get 3105 = 3 * 1035.
  4. 1000000
    Returns: "Impossible"
  5. 100035
    Returns: "Possible"
  6. 4
    Returns: "Impossible"
Back to all problems