1083 是否存在相等的差 (20 分)
#include <iostream> #include <cmath> using namespace std; int arr[1 << 20]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { int x, t; cin >> x; t = abs(x - i); arr[t]++; } for (int i = 10000; i >= 0; i--) { if (arr[i] > 1) {. //既然是重复就一定要大于一 cout << i << ' ' << arr[i] << endl; } } return 0; }