0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 18:48:48 +00:00

P2141 [NOIP2014 普及组] 珠心算测验

R63301836
This commit is contained in:
Baoshuo Ren 2021-11-21 18:58:58 +08:00 committed by Baoshuo Ren
parent 2384573091
commit 842ce30e1f
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

26
Luogu/P2141/P2141.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <bits/stdc++.h>
using namespace std;
int n, a[105], ans;
bool vis[105];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a + 1, a + 1 + n);
for (int i = 1; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
for (int k = j + 1; k <= n; k++) {
if (a[i] + a[j] == a[k] && !vis[k]) {
ans++;
vis[k] = true;
}
}
}
}
cout << ans << endl;
return 0;
}