Breaking the Equations
Time limit1sMemory limit128 MB
Pick twelve values from the given set that satisfy the six addition equations and form the lexicographically smallest tuple.
- Level
Medium6 of 10
- Topics
- Hash map, Brute force, Sorting, Backtracking
- Solved
- No attempts yet
Problem
You are given a set . Every element of is an integer that is at least 0.
Consider these six equations.
and are integer constants. Given and , write a program that solves the equations, that is, find all twelve values through . Every must be an element of . Two different may take the same value. Only inputs whose equations can be solved are given.
Input
The first line contains , , and . Each of the next lines contains one . , and each is a 32-bit integer.
Output
Print 12 lines in total: on the first line, on the second, and so on down to on the twelfth.
If more than one solution exists, compare the tuples position by position from the front and print only the lexicographically smallest one.