mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 15:58:48 +00:00
P2141 [NOIP2014 普及组] 珠心算测验
R63301836
This commit is contained in:
parent
2384573091
commit
842ce30e1f
26
Luogu/P2141/P2141.cpp
Normal file
26
Luogu/P2141/P2141.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user