Dick and Jane
InterviewTime limit1sMemory limit128 MB
Given that Spot was s when Puff was born, Puff was p when Yertle was born, and Spot was y when Yertle was born, find the three current ages.
- Level
Medium6 of 10
- Topics
- Math, Brute force, Implementation
- Solved
- No attempts yet
Problem
Dick is 12 years old. Saying that someone is years old means that at least but strictly fewer than full years have passed since they were born — every age is rounded down to a whole number of years.
Dick and Jane have three pets: Spot the dog, Puff the cat, and Yertle the turtle. Three facts are known:
- Spot was years old when Puff was born.
- Puff was years old when Yertle was born.
- Spot was years old when Yertle was born.
Each of these ages is a whole number of years, rounded down exactly as Dick's age is. Moreover, the sum of Spot's, Puff's, and Yertle's ages equals the sum of Dick's age (which is ) and Jane's age ().
Determine the current ages of Spot, Puff, and Yertle.
Input
Each line contains four non-negative integers separated by single spaces: , , , and . Input continues until end of file, and every line describes an independent scenario.
Output
For each input line, print one line with three integers separated by single spaces: the current ages of Spot, Puff, and Yertle, in that order. Each age is a whole number of years, using the same rounding-down rule described above.