-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathD.cpp
More file actions
68 lines (63 loc) · 1.38 KB
/
D.cpp
File metadata and controls
68 lines (63 loc) · 1.38 KB
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
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define ll long long
#define Speedo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define return0 return 0
#define Endl endl
#define ull unsigned long long
#define elif else if
#define test cout<<" We Fucked up Here Boss_________________"<<endl
#define allout(first) for(auto ele : first) {cout<<ele<<" ";}cout<<endl;
ll printNcR(int n, int r)
{
long long p = 1, k = 1;
if (n - r < r)
r = n - r;
if (r != 0) {
while (r) {
p *= n;
k *= r;
long long m = __gcd(p, k);
p /= m;
k /= m;
n--;
r--;
}
}
else
p = 1;
return p;
}
int main()
{
Speedo;
int t;
cin >> t;
while (t--)
{
ll n;
cin >> n;
vector<ll>v(n);
ll k ;
unordered_map<ll, ll>mp;
for (int i = 0; i < n; i++)
{
cin>>k;
mp[k -(i+1)]++;
}
ll cnt = 0;
for (auto ele : mp)
{
if(ele.second>1)
{
cnt+=printNcR(ele.second,2);
}
}
cout << cnt << Endl;
// cout << cnt << endl;
}
}