Cycle Prefix Averages
Difficulty: Easy
Last updated
Difficulty: Easy
Last updated
Prefix Averages Algorithm is used to calculate average of the first i elements in an array. That algorithm is widely used in financial analysis. Peter, which is a financial analyst, is now wondering if he keeps repeating the prefix averages, how many times it repeats until all the numbers are same as first element. To make things simple, he will omit any trailing decimals during finding the averages instead.
The first line consists of an integer N, which is the number of arrays to input. Starting from second line, there 1D array which consist of various numbers with various size, given all integers.
Output the total count of cycle per line, which makes all numbers in an array into 1. If it is impossible to make all numbers in an array into 1, print -1 instead.
[1]:
[2]:
[7]: