题目:https://codeforces.com/problemset/problem/1541/B
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<string>
#include<functional>
#include<queue>
#include<limits>
using namespace std;
const int N = 3e5 + 10;
int ans[N], pos[N], x[N];
typedef long long ll;
#define cir(a,b,c) for(int a=b;a<=(c);++a)
#define inv(a,b,c) for(int a=b;a>=c;a--)
#define all(x) (x).begin(),(x).end();
int inf = 0x3f3f3f3f;
int main()
{
int T;
cin >> T;
while (T--)
{
int ans = 0;
int a;
int num;
unordered_map<int,int>mp;
int n;
cin >> n;
cir(i, 1, n) { int x; cin >> x; mp[x] = i; }//tag
cir(num, 3, 2 * n - 1)//why
{
cir(a, 1, num / a)//guarntee a<b
{
if (num % a == 0)
{
int b = num / a;//demand multiplication
if (a == b) { continue; }
if (mp.count(a) &&mp.count(b))
{
if (mp[a] + mp[b] == num)//demand plus
{
++ans;
}
}
}
}
}
cout << ans << endl;
}
}