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.

24 lines
670 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;
//这题30分的一般都是没有去重……1+4=5和2+3=5算同一个……
//这道题还是挺有意思的,注意,前方有坑!需要理解 5=1+4=2+3但5只算一次的道理。
const int N = 110;
int n;
int a[N];
bool b[N]; //标识已使用
int cnt;
int main() {
cin >> n;
for (int i = 1; i <= n; i++)cin >> a[i];
//暴力三层循环+标识数组
for (int i = 1; i < n; i++)
for (int j = i + 1; j <= n; j++)
for (int k = 1; k <= n; k++)
if (a[k] == a[i] + a[j] && !b[k]) cnt++, b[k] = true;
printf("%d", cnt);
return 0;
}