Hi Everyone,
I was working on the USACO 2020 December Contest Bronze Problem 2, and I did not understand the problem statement.
Here is my code:
public class UsacoPractice7
{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String numOfFlowers = br.readLine();
String amountOfPetals = br.readLine();
String[] petals = amountOfPetals.split(" ");
int size = petals.length;
int [] arr = new int [size];
for(int i = 0; i < size; i++)
{
arr[i] = Integer.parseInt(petals[i]);
}
List<Integer> listOfPetals = new ArrayList<>(arr.length);
for (int i : arr)
{
listOfPetals.add(Integer.valueOf(i));
}
//System.out.println(listOfPetals);
int count = listOfPetals.size();
for(int i = 0; i < listOfPetals.size(); i++)
{
int sum = listOfPetals.get(i);
for(int j = i + 1; j < listOfPetals.size(); j++)
{
sum = sum + listOfPetals.get(j);
if (sum % (j - i + 1) == 0)
{
count++;
}
}
}
System.out.println(count);
}
}