Permutiple
SRM 716 · 2017-05-20 · by cgy4ever
Problem Statement
Return "Possible" if this can be done and "Impossible" otherwise. Note that the return value is case-sensitive.
Constraints
- x will be between 1 and 1,000,000, inclusive.
Statement by TopCoder, Inc. — view the original on the archive.
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).
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.
1035 Returns: "Possible"
We can get 3105 = 3 * 1035.
1000000 Returns: "Impossible"
100035 Returns: "Possible"
Submissions are judged against all 108 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Permutiple with a public method string isPossible(int x) · 108 test cases · 2 s / 256 MB per case