Junior — Senior
Determining the value of D from a mixed set of numbers
livecode
Task condition
Given four distinct positive integers A, B, C, and D, sorted in ascending order: A<B<C<D. The program receives eight numbers in arbitrary order: the numbers A, B, C, D, and their pairwise products AB, BC, CD, DA. Write a program that determines and outputs the value of D.
Input format A single line contains eight integers — a shuffled set of A, B, C, D, AB, BC, CD, DA.
Output format Output a single number — the found value of D.
Example 1 Input: 2 3 4 1 12 6 2 4 Output: 4
Example 2 Input: 2 6 7 3 14 3 15 5 Output: 7
Example 3 Input: 1 1971 78 7644 98 27 5694 73 246 Output: 98