QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 2048 MB Total points: 100

#7912. 修复分数

Statistics

数学很难。但它本可以更简单!互联网™ 找到了一些让它变得更简单的好方法。看看下面这些“正确”的等式:

$$\log(1) + \log(2) + \log(3) = \log(1 + 2 + 3)$$ $$\frac{163}{326} = \frac{1}{2}$$

遵循这些模式,我们得出结论,下面的等式也应该是成立的:

$$\frac{123}{234} = \frac{1}{2}$$

然而,在枯燥的传统数学中,这实际上是错误的。因此,我们定义了一种新的“时髦数学”,允许在等号左侧消去相同的数字。这肯定会让每个人的生活都变得更轻松。除了你,因为你必须判断两个给定的分数在我们的这种新式数学中是否相等。

输入格式

输入包含: * 一行包含四个整数 $a, b, c$ 和 $d$ ($1 \le a, b, c, d < 10^{18}$),描述了两个分数 $\frac{a}{b}$ 和 $\frac{c}{d}$。

输出格式

如果存在整数 $a'$ 和 $b'$,它们是通过从 $a$ 和 $b$ 中消去相同的数字得到的,并且在标准数学中满足 $\frac{a'}{b'} = \frac{c}{d}$,则输出 “possible”,随后输出 $a'$ 和 $b'$。否则,输出 “impossible”。

如果有多个有效的解,你可以输出其中任意一个。

注意:消去数字后,$a'$ 和 $b'$ 均不允许包含前导零。

样例

样例输入 1

163 326 1 2

样例输出 1

possible
1 2

样例输入 2

871 1261 13 39

样例输出 2

possible
87 261

样例输入 3

123 267 12339 23679

样例输出 3

impossible

Figure 1. A meme depicting people holding Einstein back, illustrating the absurdity of the 'funky math' described.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.