CF2181H.Honey Cake

普及-

通过率:0%

时间限制:3.00s

内存限制:1024MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Hannah and Henry are going to host a party for nn people, including themselves.

They bought a honey cake of size w×h×dw \times h \times d inches for the party, and want to split it into nn equal pieces.

The honey cake can be cut parallel to any of its faces. To make cuts precise, each edge of length ww is cut into the same number of equal parts, each having integer length; similarly for edges of lengths hh and dd.

Given the dimensions of the honey cake, determine whether it is possible to cut it into nn equal pieces, and if so, how.

汉娜和亨利将为 nn 个人(包括他们自己)举办一场派对。

他们为派对购买了一块尺寸为 w×h×dw \times h \times d 英寸的蜂蜜蛋糕,希望将其切成 nn 块大小相等的部分。

蜂蜜蛋糕只能沿其任意一个面的平行方向进行切割。为了确保切割精确,长度为 ww 的每条棱必须被切割成若干段相等的部分,且每段长度均为整数;同理,长度为 hh 和 dd 的棱也需如此处理。

给定蜂蜜蛋糕的尺寸,判断是否能将其切成 nn 块大小相等的部分;若可以,请说明具体切法。

输入格式

The first line of input contains three integers: ww, hh, and dd, the dimensions of the honey cake in inches (1≤w,h,d≤1091 \le w, h, d \le 10^9).

The second line contains a single integer nn (1≤n≤1091 \le n \le 10^9).

输入的第一行包含三个整数:ww、hh 和 dd,分别表示蜂蜜蛋糕的长、宽、高(单位:英寸),满足 1≤w,h,d≤1091 \le w, h, d \le 10^9。

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

输出格式

Output three integers wcw_c, hch_c, dcd_c, the number of cuts to be made along each of the dimensions ww, hh, and dd, respectively, if it is possible to cut the cake, or a single integer −1-1 otherwise. Note that making zero cuts along a dimension is allowed, too.

输出三个整数 wcw_c、hch_c、dcd_c,分别表示沿维度 ww、hh 和 dd 所需进行的切分次数;若无法切分该蛋糕,则仅输出一个整数 −1-1。注意:沿某一维度不进行任何切分(即切分次数为零)是允许的。

输入输出样例

  • 输入#1

    10 20 6
    40

    输出#1

    4 3 1

说明/提示

In the first example, the cake will be cut into 5⋅4⋅2=405 \cdot 4 \cdot 2 = 40 pieces of size 2×5×32 \times 5 \times 3 inches.

在第一个例子中,蛋糕将被切成 5⋅4⋅2=405 \cdot 4 \cdot 2 = 40 块,每块尺寸为 2×5×32 \times 5 \times 3 英寸。

输入解题思路,AI测评打分。不知道怎么写?

首页