第 21 场 Codeforces Alpha Round(Codeforces 赛制)
C
条纹 2
Stripe 2
Codeforces
2000
原题
← BD →

条纹 2AI (CI翻译)

Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into three pieces so that the sum of numbers from each piece is equal to the sum of numbers from any other piece, and each piece contains positive integer amount of squares. Would you help Bob solve this problem?

Bob 曾经拿到一条由 $n$ 个方格组成的纸条(纸条的高度为 1 个方格)。他在每个方格中写下一个整数,这些整数可能为负数。他想知道,有多少种方法可以把这条纸带切成三段,使得每段中所有数字的和都相等,并且每段都包含正整数个方格。你能帮 Bob 解决这个问题吗?AI (CI翻译)

Input

输入格式

AI (CI翻译)

The first input line contains integer $*n*$ ($1 ≤ *n* ≤ 10^{5}$) — amount of squares in the stripe. The second line contains n space-separated numbers — they are the numbers written in the squares of the stripe. These numbers are integer and do not exceed 10000 in absolute value.

输入的第一行包含整数 $*n*$ ($1 ≤ *n* ≤ 10^{5}$),表示纸条上的方格数。第二行包含 n 个以空格分隔的数字,表示写在方格中的数。这些数均为整数,且绝对值不超过 10000。AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output the amount of ways to cut the stripe into three non-empty pieces so that the sum of numbers from each piece is equal to the sum of numbers from any other piece. Don't forget that it's allowed to cut the stripe along the squares' borders only.

输出把纸条切成三段非空部分、使得每段中的数字之和都相等的切法数。注意,只能沿方格的边界切割。AI (CI翻译)

样例

Input #1
4
1 2 3 3
Output #1
1
InputCopy OutputCopy
Input #2
5
1 2 3 4 5
Output #2
0
InputCopy OutputCopy
题目信息
题号
21C
时间限制
1 s
内存限制
64 MB
标签
二分
动态规划
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。