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

26 lines
719 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#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;
}