Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
2.2 kB
7
Indexable
Never
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
#define ll long long 

ll bin_multiply(ll a, ll b , ll M){
	ll ans=0;
	while(b>0){
		if(b&1){
			ans=(ans+a)%M;
		}
		a=(a+a)%M;
		b>>=1;
	}
	return ans;
}
ll my_power(ll a ,ll b, ll M){
	ll ans=1;
	while(b>0){
		if(b&1){
			ans=bin_multiply(ans,a,M);
		}
		a=bin_multiply(a,a,M);
		b>>=1;
	}
	return ans;
}
ll inverse(ll a, ll M){
	return my_power(a,M-2,M);
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	return gcd(b,b%a);
}
ll lcm(ll a,ll b,ll M){
	return bin_multiply(a,b,M)/gcd(a,b);
}

int main() {
	#define int long long
	ll t=1;
	cin>>t;
	while(t--){
		int n;
        cin>>n;
        vector<pair<int,int> > v(n);
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            v[i]=make_pair(x,i+1);
        }
        sort(v.begin(),v.end());
        int count=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(v[i].first *v[j].first > 2*n)
                break;
                if(v[i].first *v[j].first==v[i].second +v[j].second)
                count++;
            }
        }
        cout<<count<<endl;

	}
	return 0;
}