#P14789. [NERC 2025] Honey Cake

    ID: 14718 远端评测题 3000ms 1024MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>数学2025Special JudgeICPCNERC/NEERC

[NERC 2025] Honey Cake

Description

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.

Input Format

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

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

Output Format

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.

10 20 6
40
4 3 1

Hint

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

:::align{center} :::