PAT 乙级 1083 是否存在相等的差
题目
输入样例:
8
3 5 8 6 2 1 4 7
输出样例:
5 2
3 3
2 2
原题链接
源码:
#include<stdio.h>
int main()
{int shuzu[10010] = { 0 }, n, a, b;scanf("%d", &n);for (int i = 1; i <= n; i++) {scanf("%d", &a);if (a > i)b = a - i;else b = i - a;shuzu[b]++;}for (int i = 10000; i>=0; i--) {if (shuzu[i] > 1)printf("%d %d\n", i, shuzu[i]);}return 0;
}