#P1215. Milk Pouring Problem
Milk Pouring Problem
Milk Pouring Problem
Farmer John has three buckets with capacities \(a\), \(b\), and \(c\) liters. Initially, buckets \(a\) and \(b\) are empty, and bucket \(c\) is full of milk. He can pour milk from one bucket to another. In each pour, he transfers milk until either the source bucket is empty or the destination bucket is full. No milk is spilled during the process.
Your task is to help Farmer John determine all the possible amounts of milk that can remain in bucket \(c\) when bucket \(a\) is empty. The final answer should list these amounts in increasing order.
inputFormat
The input consists of a single line with three integers \(a\), \(b\), and \(c\) (\(1 \leq a, b, c \leq 20\)), representing the capacities of buckets \(a\), \(b\), and \(c\) respectively. Initially, bucket \(c\) is full, and buckets \(a\) and \(b\) are empty.
outputFormat
Output a single line containing all the possible amounts of milk (in liters) that can be in bucket \(c\) when bucket \(a\) is empty. The numbers must be sorted in increasing order and separated by a single space.
sample
8 9 10
1 2 8 9 10