Given a list of numbers (e.g. N = 4), we slice a sublist from this list. The sublist could contain any amount of numbers from 1 to the whole list. Find out how many sublists have a number which is the average number for this sublist.
Sample Input: input.txt
4
3 3 1 2
Sample Output: output.txt
6
For the above sample input, the sublists that have an average number are: 3, 3, 1, 2, [3, 3], [3, 1, 2]
USACO 编程竞赛概要: 铜级题 #2
给定一个数列A(譬如:4个数字),我们从数列中切割出所有可能的子数列,子数列的长度可以从1一直到数列A的长度,找出有多少子数列里面包括平均数值的数字,譬如子数列 (3, 3) 的平均数值是3。
输入样例: input.txt
4
3 3 1 2
输出样例: output.txt
6
上面输入样例中,包含平均数值的子数列总共有六个:3,3,1,2,[3, 3], [3, 1, 2]
Python Solution: