QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#20978. 데이지 꽃 사슬

Statistics

소 Bessie는 매일 농장을 산책하면서 가장 좋아하는 목초지에 방문한다. 그곳에는 $1\ldots N$으로 번호가 매겨진 $N$개의 꽃(모두 다채로운 데이지)이 한 줄로 있다($1\le N \le 100$). 꽃 $i$에는 꽃잎 $p_i$개가 있다($1 \le p_i \le 1000$).

초보 사진가인 Bessie는 이 꽃들을 여러 장 찍기로 한다. 구체적으로 $1\le i\le j\le N$을 만족하는 모든 꽃 쌍 $(i,j)$에 대해 꽃 $i$부터 꽃 $j$까지의 모든 꽃($i$와 $j$ 포함)을 사진에 담는다.

나중에 사진을 본 Bessie는 일부 사진에 "평균 꽃"이 있음을 발견한다. 이는 꽃잎이 $P$개인 꽃으로, $P$는 사진 속 모든 꽃의 꽃잎 수의 정확한 평균이다.

Bessie의 사진 중 평균 꽃이 있는 사진은 몇 장인가?

입력

입력의 첫 줄에는 $N$이 주어진다. 두 번째 줄에는 공백으로 구분된 $N$개의 정수 $p_1 \dots p_N$이 주어진다.

출력

평균 꽃이 있는 사진의 수를 출력한다.

예제

입력 1

4
1 1 2 3

출력 1

6

참고

꽃 하나만 담긴 모든 사진은 개수에 포함된다(예제에는 네 장 있다). 또한 예제의 $(i,j)$ 구간 $(1,2)$와 $(2,4)$도 평균 꽃이 있는 사진에 해당한다.

문제 작성자: Nick Wu

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.