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;
}















![[AndroidStudio]_[初级]_[修改虚拟设备镜像文件的存放位置]](https://img-blog.csdnimg.cn/04cebe41940c400ebae57bcfd902240a.png)



