#K78382. Product of Integers Excluding Extremes
Product of Integers Excluding Extremes
Product of Integers Excluding Extremes
You are provided with a comma-separated string of integers. Your task is to compute the product of all the integers after removing the smallest and largest values.
If the input string is empty, or if removing the smallest and largest integers leaves no integers, the program should output None
.
For example, given the input "1,2,3,4,5"
, the smallest and largest values are 1 and 5 respectively. The remaining values are 2, 3, and 4, and their product is 24.
The formula for the operation can be expressed in LaTeX as follows:
\[ \text{result} = \prod_{i=2}^{n-1} a_{(i)} \]
where \(a_{(i)}\) is the \(i\)-th smallest number after sorting the list of integers, and \(n\) is the total count of the integers.
inputFormat
The input consists of a single line read from standard input (stdin
). This line contains a comma-separated list of integers. The input string may be empty.
outputFormat
Output the product of the integers, excluding the smallest and largest values, to standard output (stdout
). If the input is empty or the removal of the smallest and largest integers would result in an empty list, output None
.
1,2,3,4,5
24