#P9956. [USACO20DEC] Daisy Chains B
[USACO20DEC] Daisy Chains B
Problem Description
Every day, as part of her walk around the farm, Bessie the cow passes by her favorite pasture, where there are flowers (colorful daisies), numbered (), arranged in a line. Flower has petals ().
As an aspiring photographer, Bessie decides to take some photos of these flowers. Specifically, for every pair satisfying , Bessie takes a photo of all flowers from flower to flower (including and ).
Later, when Bessie looks at these photos, she notices that some photos contain an “average” flower: a flower that has exactly petals, where equals the average number of petals among all flowers in the photo.
How many of Bessie’s photos contain an average flower?
Input Format
The first line contains . The second line contains space-separated integers .
Output Format
Output the number of photos that contain an average flower.
4
1 1 2 3
6
Hint
Sample Explanation 1
Every photo that contains only one flower is counted in the answer (there are such photos in this sample). In addition, in this sample, the photos corresponding to equal to and also contain an average flower.
Translated by ChatGPT 5