QOJ.ac

QOJ

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

#20978. שרשראות חינניות

Statistics

בכל יום, כחלק מהטיול שלה בחווה, הפרה Bessie מבקרת במרעה האהוב עליה. בו יש $N$ פרחים (כולם חינניות צבעוניות), הממוספרים $1\ldots N$ ומסודרים בשורה ($1\le N \le 100$). לפרח $i$ יש $p_i$ עלי כותרת ($1 \le p_i \le 1000$).

כצלמת מתחילה, Bessie מחליטה לצלם כמה תמונות של הפרחים. בפרט, עבור כל זוג פרחים $(i,j)$ המקיים $1\le i\le j\le N$, היא מצלמת את כל הפרחים מהפרח $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.