QOJ.ac

QOJ

実行時間制限: 3.0 s メモリ制限: 1024 MB 満点: 100

#15900. 蜂蜜蛋糕

統計

Hannah 和 Henry 准备举办一个有 $n$ 个人(包括他们自己)参加的聚会。

他们为聚会买了一个尺寸为 $w \times h \times d$ 英寸的蜂蜜蛋糕,并希望将其切成 $n$ 个等份。

蜂蜜蛋糕可以平行于其任意表面进行切割。为了使切割精确,长度为 $w$ 的每条棱都要被切成相同数量的等份,且每份的长度必须为整数;对于长度为 $h$ 和 $d$ 的棱也是如此。

给定蜂蜜蛋糕的尺寸,请确定是否可以将其切成 $n$ 个等份,如果可以,给出具体的切割方案。

输入格式

第一行包含三个整数 $w$、$h$ 和 $d$,表示蜂蜜蛋糕的尺寸(以英寸为单位)($1 \le w, h, d \le 10^9$)。

第二行包含一个整数 $n$($1 \le n \le 10^9$)。

输出格式

如果可以切出蛋糕,输出三个整数 $w_c, h_c, d_c$,分别表示沿维度 $w$、$h$ 和 $d$ 进行的切割次数。否则,输出单个整数 $-1$。注意,允许在某个维度上进行 $0$ 次切割。

样例

输入样例 1

10 20 6
40

输出样例 1

4 3 1

说明

在第一个样例中,蛋糕将被切成 $5 \cdot 4 \cdot 2 = 40$ 块,每块的尺寸为 $2 \times 5 \times 3$ 英寸。

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.