//这是我的代码 你能确定它的时间复杂度吗 第一个循环很简单 o(n) 但第二个循环应该是 o(logn) 但我不知道怎么做? 我一直在粗略地计算,但我很困惑
#include <bits/stdc++.h>
typedef long long int ll;
const unsigned int MOD = 1000000007;
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
for (int tt = 0; tt < t; tt++)
{
int n;
cin >> n;
ll a[n+1];
for (int i = 1; i < n+1; i++)
{
cin>>a[i];
}
int ans = 0;
for (int i = 1; i <= n; i++)
{
for (int j = a[i] - i; j <= n; j += a[i])
{
if (j >= 0)
if (a[i] * a[j] == i + j && i < j)
ans++;
}
}
cout << ans << endl;
}
return 0;
}