/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: northwest.cpp * Author: cteam025 * * Created on October 28, 2017, 9:42 AM */ #include using namespace std; int main(int argc, char** argv) { ios::sync_with_stdio(false); int n; while (cin >> n) { if (n == 0) { cout << 0 << endl; continue; } map nw, ne; for (int i = 0; i < n; i++) { long long x, y; cin >> x >> y; if (nw.find(x+y) == nw.end()){ nw.insert(make_pair(x+y, 0)); } if (ne.find(x-y) == ne.end()){ ne.insert(make_pair(x-y, 0)); } nw[x+y]++; ne[x-y]++; } long long win = 0; long long tmp; for (auto p : nw) { tmp = p.second; // cout << p.first << " " << p.second << endl; // cout << tmp * (tmp-1) << endl; win += tmp * (tmp-1); } for (auto p : ne) { tmp = p.second; // cout << p.first << " " << p.second << endl; // cout << tmp * (tmp-1) << endl; win += tmp * (tmp-1); } cout << setprecision(6) << (win/(double)((double)n*n)) << endl; } return 0; }