#include #include // double prob_line(int count, int total) // { // double ret = 0; // while(count--) { // double tmp = 0; // tmp += 2*count; // tmp /= total*total; // ret += tmp; // } // return ret; // } int factorial(int N){ int result = 1; while (N > 0){ result *= N; N--; } return result; } double combinate(int n, int k){ int bigger = k > n -k? k : n-k; int smaller = k < n -k? k : n-k; int result = 1; while( n > bigger ) { result *= n; n--; } return ((double)result)/factorial(smaller); } double get_prob(std::map& map, int total) { std::map::iterator it = map.begin(); double ret = 0; while(it != map.end()) { ret += it->second*it->second - it->second; it++; } return (ret); } int main() { int N; int total; while(scanf("%d", &N) != EOF) { std::map map_right, map_left; total = N; double res = 0; while(N--) { int x, y; scanf("%d %d" , &x, &y); if ( map_right.end() == map_right.find(y-x)) map_right[y-x] = 0; map_right[y-x]++; if ( map_left.end() == map_left.find(y+x)) map_left[x+y] = 0; map_left[y+x]++; } res += get_prob(map_right, total); res += get_prob(map_left, total); printf("%.6g\n", res/(total*total)); } return 0; }