T-T
2024-07-27 14:55:36
发布于:上海
0阅读
0回复
0点赞
#include <iostream>
using namespace std;
int main() {
int n, sum;
int a[10000];
int b[10000] = {0};
long long cnt = 0;
cin >> n >> sum;
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
b[a[i] + a[j]]++;
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (sum - a[i] - a[j] > 0)
{
cnt += b[sum - a[i] - a[j]];
}
}
}
cout << cnt;
return 0;
}
这里空空如也
有帮助,赞一个