Skip to main content
Back to problems
Codeforces
Easy
Math
Geometry
Number Theory
Parallelepiped

Find the three edge lengths of a rectangular parallelepiped from the pairwise face diagonals.

Acceptance 0%
Problem Statement

Parallelepiped

You are given three positive integers representing the areas of three pairwise adjacent rectangular faces of a rectangular parallelepiped (box).

Let the edge lengths be aa, bb, and cc. Then the three face areas are:

  • abab
  • acac
  • bcbc

Your task is to recover one valid triple (a,b,c)(a, b, c) of positive integers that matches the given face areas.

If multiple answers are possible, any valid one is acceptable.

Notes

  • The three given values are guaranteed to come from some integer box.
  • The order of the three edges in the output does not matter.

Input Format

The input consists of three integers xx, yy, and zz — the areas of the three faces.

Output Format

Print three positive integers aa, bb, and cc such that:

  • ab=xab = x
  • ac=yac = y
  • bc=zbc = z

Any valid ordering is accepted.

Constraints

  • 1≤x,y,z≤1091 \le x, y, z \le 10^9
  • A valid integer solution exists.

Hints

  • Try multiplying the three equations together.
  • Once you know abcabc, each edge length can be recovered by dividing by the right face area and taking a square root where appropriate.

Input Format

Three integers xx, yy, and zz representing the areas of three pairwise adjacent faces.

Output Format

Print three positive integers aa, bb, and cc such that ab=xab=x, ac=yac=y, and bc=zbc=z.

Constraints

  • 1≤x,y,z≤1091 \le x, y, z \le 10^9
  • A valid integer solution exists.
Examples
Sample cases returned by the problem API.

Example 1

Input

4 6 3

Output

2 2 3

Explanation

A valid set is a=2a=2, b=2b=2, c=3c=3, which gives face areas ab=4ab=4, ac=6ac=6, and bc=6bc=6. Since the input is intended to match the three pairwise face areas, the output demonstrates the recovery idea rather than this exact sample.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.