#P1618. Three Three-Digit Numbers with a Given Ratio
Three Three-Digit Numbers with a Given Ratio
Three Three-Digit Numbers with a Given Ratio
Given the digits (1, 2, \ldots, 9), divide them into three groups to form three three-digit numbers (X, Y, Z) such that their ratio is (A:B:C). Each digit from 1 to 9 must be used exactly once. If there is no solution, output No!!!
.
The mathematical formulation is as follows: Find an integer (k) such that
[
X = A\cdot k,\quad Y = B\cdot k,\quad Z = C\cdot k,
]
with (100 \leq X, Y, Z \leq 999) and the concatenation of the digits of (X, Y, Z) in that order is a permutation of ({1,2,\ldots,9}).
inputFormat
Input consists of three positive integers A, B, and C separated by spaces.
outputFormat
For each valid solution, output the three numbers in one line separated by a single space. If there are multiple solutions, output each solution on a separate line in ascending order by the first number. If no valid solution exists, output No!!!
sample
1 2 3
192 384 576