You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
622 B
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int a[350];
int main()
{
int n;
while (cin >> n)
{
for (int i = 1; i <= n; i++)
scanf("%d", a + i);
for (int i = 2; i <= n; i++)
a[i] += a[i - 1];
int sum = a[n];
int cnt = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < i; j++)
if (2 * (a[i] - a[j]) == sum)
cnt++;
cout << (1ll * cnt * (cnt - 1) / 2) << endl;
}
return 0;
}