- P205's solution
-
P205's Solution
- @ 2026-1-5 0:28:49
题目中的等式等价于:
$$2 \cdot \sum _{i = 1} ^x a_i = \sum _{i = 1} ^n a_i$$等式右边是定值,左边可以用一次前缀和 算出所有 值对应的计算结果,逐个判断即可。
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 12;
long long t[N];
int main()
{
long long n, x, s = 0, a = 0;
while (cin >> n)
{
s = 0;
for (int i = 1; i <= n; i++)
{
cin >> x;
s += x;
t[i] = s;
}
a = 0;
for (int i = 0; i <= n; i++)
if (2 * t[i] == s) a++;
cout << a << endl;
}
return 0;
}