#P5697. Johnny's Toy Collection
Johnny's Toy Collection
Johnny's Toy Collection
Johnny loves collecting toys. He owns many types of toys and has multiple copies of each type. Note that two toys of the same type are indistinguishable.
When Emma asked him how many toys he had, Johnny refused to give a direct answer. Instead, he said that if he were to select some toys from his collection (the empty selection is allowed), he could play for exactly \( n \) days. In other words, he can prepare \( n \) different selections such that for any two different days, there is at least one type of toy for which the number selected is different.
If Johnny has \( k \) types of toys and for each type \( i \) he owns \( a_i \) toys, then on any day he can choose anywhere from 0 to \( a_i \) toys of that type. The total number of distinct selections he can make is given by:
\( \prod_{i=1}^{k} (a_i+1) = n \)
The total number of toys he owns is:
\( T=\sum_{i=1}^{k} a_i = \sum_{i=1}^{k} (f_i-1) \)
where for each type \( f_i = a_i+1 \) (with \( f_i\ge2 \)). Emma wants to know all possible values of \( T \) that are consistent with Johnny being able to form exactly \( n \) distinct selections. For example, if \( n=6 \), one possible configuration is to have one type with \( a_1=5 \) (since \( 5+1=6 \)), giving \( T=5 \); another is to have two types with \( a_1=1 \) and \( a_2=2 \) (since \( (1+1)\times(2+1)=6 \)), giving \( T=1+2=3 \). The answer for \( n=6 \) would then be both 3 and 5, ordered in increasing order.
inputFormat
The input consists of a single integer \( n \) representing the number of distinct selections Johnny can make from his toy collection. You may assume \( n \) is a positive integer (\( n \ge 1 \)).
outputFormat
Output all distinct possible total numbers of toys \( T \) that Johnny could have, in ascending order, separated by a single space.
sample
6
3 5
</p>