#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; } double get_prob(std::map& map, int total) { std::map::iterator it = map.begin(); double ret = 0; while(it != map.end()) { ret += prob_line(it->second, total); 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); } return 0; }