Sequences + Longest Common Subsequence
Find a multiple
The input contains n positive integers. Each of that numbers is not greater than 15000. This numbers are not necessarily different (so it may happen that two or more of them will be equal). Your task is to choose a few of given numbers (1 ≤ few ≤ n) so that the sum of chosen numbers is multiple for n (i.e. n * k = (sum of chosen numbers) for some integer k).
The first line contains the single number n (n ≤ 10000). Each of next n lines contains one number from the given set.
In case your program decides that the target set of numbers can not be found it should print the single number 0. Otherwise it should print the number of the chosen numbers in the first line followed by the chosen numbers themselves (on a separate line each) in arbitrary order.
If there are more than one set of numbers with required properties you should print only one (preferably your favorite) of them.
5 1 2 3 4 1
2 2 3