1.
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
const int N = 1010;
int t, n;
int a[N], b[N];
set<int> st;
int g[N][N];
int main()
{
scanf("%d", &t);
while (t --)
{
scanf("%d", &n);
st.clear();
memset(g, 0, sizeof g);
int k = 0;
for (int i = 0; i < n; ++ i)
{
scanf("%d", &a[i]);
st.insert(a[i]);
}
for (int i = 0; i < n; ++ i)
{
scanf("%d", &b[i]);
k = max(k, b[i]);
g[b[i]][a[i]] ++;
}
int flag = 0, cnt = 1;
for (int i = 1; i <= k; ++ i)
{
printf("%d={", i);
int flag = 0;
for (auto ch : st)
{
if (flag)
printf(",");
else
flag = 1;
printf("%d=%d", ch, g[i][ch]);
}
printf("}\n");
}
}
return 0;
}
2.
#include<iostream>
using namespace std;
int main()
{
int n;
cin >> n;
while (n --)
{
int m, a[100];
cin >> m;
for (int i = 0; i < m; i ++) cin >> a[i];
int count = 0;
for (int i = 0; i < m; i ++)
for (int j = 0; j < m; j ++)
for (int k = 0; k < m; k ++)
if (a[i] + a[j] == a[k])
count ++;
cout << count << '\n';
}
return 0;
}