-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1541_B_Pleasent_Pairs.cpp
86 lines (59 loc) · 1.05 KB
/
1541_B_Pleasent_Pairs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <cassert>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <random>
#include <iomanip>
#include <chrono>
#include <bitset>
#include <queue>
#include <complex>
#include <functional>
#define f(i,a,b) for(ll i = a;i < b;i++)
typedef long long ll;
using namespace std;
const ll INF = 1e9 + 7;
ll md = 998244353;
int const maxi = 2000;
int a[maxi][maxi];
void solve()
{
ll n;
cin>>n;
int cnt = 0;
ll a[n+1];
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
for(ll i=1;i<=n;i++)
{
for(ll j = a[i]-i;j<=n;j+=a[i])
{
if(j <= i)
{
continue;
}
if(i+j == a[i]*a[j])
{
cnt++;
}
}
}
cout<<cnt<<"\n";
}
int main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}