#include #include using namespace std; int main() { int n; while (scanf("%d", &n) > 0) { map dia1; map dia2; for (int i = 0; i < n; i++) { int x, y; scanf("%d %d", &x, &y); dia1[x + y] += 1; dia2[y - x] += 1; } double prob = 0; for (map::const_iterator it = dia1.begin(); it != dia1.end(); it++) { //printf("dia1: %d -> %d\n", it->first, it->second); if (it->second > 1) { double p1 = (double)(it->second) / (double)n; double p2 = (double)(it->second - 1) / (double)n; prob += p1 * p2; } } for (map::const_iterator it = dia2.begin(); it != dia2.end(); it++) { //printf("dia2: %d -> %d\n", it->first, it->second); if (it->second > 1) { double p1 = (double)(it->second) / (double)n; double p2 = (double)(it->second - 1) / (double)n; prob += p1 * p2; } } printf("%lf\n", prob); } return 0; }