solution
输出的是重复的差值,而非全部差值
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e4 + 10;
int flag[maxn] = {0};
int main(){int n, x;scanf("%d", &n);for(int i = 1; i <= n; i++){scanf("%d", &x);flag[abs(i - x)]++;}for(int i = maxn - 1; i >= 0; i--){if(flag[i] > 1) printf("%d %d\n", i, flag[i]);}return 0;
}