Files
python/TangDou/CSP-J/AcWingTraining/T4/457.cpp

26 lines
719 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
/*
由于每个数的范围都在10000以内,因此两个数的和在20000以内,所以可以开一个长度是20000的bool数组,
然后枚举所有数对,将所有计算出的两数之和标记一下。
然后再枚举每个数,利用bool数组判断它是否是某两个数的和。
*/
int n;
int a[N];
bool st[20010];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
for (int i = 0; i < n; i++)
for (int j = 0; j < i; j++)
st[a[i] + a[j]] = 1;
int res = 0;
for (int i = 0; i < n; i++) res += st[a[i]];
printf("%d\n", res);
return 0;
}