Problem - 1520D - Codeforces
解析:
统计 a [ i ] - i
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
int t,n,a[N];
signed main(){
scanf("%lld",&t);
while(t--){
scanf("%lld",&n);
map<int,int>mp;
int res=0;
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
res+=mp[a[i]-i];
mp[a[i]-i]++;
}
printf("%lld\n",res);
}
return 0;
}