mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-30 15:36:27 +00:00
P3799 妖梦拼木棒
R55412792
This commit is contained in:
parent
a503db7bf7
commit
0895f652d6
37
Luogu/problem/P3799/P3799.cpp
Normal file
37
Luogu/problem/P3799/P3799.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int mod = 1e9 + 7;
|
||||
|
||||
int n, maxa, a[100005], num[100005];
|
||||
long long ans;
|
||||
|
||||
long long C(long long x, long long k) {
|
||||
return (k == 1ll ? x : x * (x - 1ll) / 2ll) % mod;
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
for (int i = 0; i < n; i++) {
|
||||
cin >> a[i];
|
||||
maxa = max(maxa, a[i]);
|
||||
num[a[i]]++;
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (num[i] >= 2ll) {
|
||||
long long times = C(num[i], 2ll) % mod;
|
||||
for (int j = 1; j <= i / 2; ++j) {
|
||||
if (j != i - j && num[j] >= 1 && num[i - j] >= 1) {
|
||||
ans += times * C(num[j], 1) * C(num[i - j], 1) % mod;
|
||||
}
|
||||
if (j == i - j && num[j] >= 2) {
|
||||
ans += times * C(num[j], 2) % mod;
|
||||
}
|
||||
ans %= mod;
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user