#P13705. [NWERC 2023] Fixing Fractions
[NWERC 2023] Fixing Fractions
题目描述
Maths is hard. But it could be easier! And the internet™ has found some excellent ways to make it easier.
:::align{center} Source: The Internet™. :::
Take a look at the following true equations:
$$\begin{aligned} \displaystyle\log(1)+\log(2)+\log(3)&=\displaystyle\log(1+2+3)\\ \displaystyle\frac{1\cancel{63}}{\cancel{3}2\cancel{6}}&=\displaystyle\frac{1}{2}~. \end{aligned} $$Following the patterns, we come to the conclusion that the following equation should also be true:
$$\displaystyle\frac{12\cancel{3}}{2\cancel{3}4}=\frac{1}{2}~. $$However, this is actually wrong in boring old standard maths. Therefore, we define a new kind of funky maths where it is allowed to cancel out digits on the left side of the equality sign. This surely will make everyone's life easier. Except yours, since you have to evaluate if two given fractions are equal in our new funky maths.
输入格式
The input consists of:
- One line with four integers , , , and (), describing the two fractions and .
输出格式
If there exist integers and obtained from and by cancelling out the same digits and with in standard mathematics, output "", followed by and . Otherwise, output "".
If there are multiple valid solutions, you may output any one of them.
Note that neither nor is allowed to contain leading zeroes after cancelling digits.
163 326 1 2
possible
1 2
871 1261 13 39
possible
87 261
123 267 12339 23679
impossible