/* * 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. */ package northwest; import java.util.Scanner; /** * * @author hlavaty7 */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int pocet; int[][] pole; while (sc.hasNext()) { pocet = sc.nextInt(); pole = new int[pocet + 1][pocet + 1]; int r, s; for (int i = 0; i < pocet; i++) { r = sc.nextInt(); s = sc.nextInt(); // pole[r - 1][s - 1] = 1; pole[r][s] = 1; } double ries = ries(pole,pocet); System.out.println(ries); } } private static int nasiel(int[][] pole, int r, int s) { int[] moves = {-1, 1}; int r1 = r - 1; int s1 = s - 1; int vysl = 0; while (r1 >= 0 && s1 >= 0) { if (pole[r1][s1] == 1) { vysl++; } r1 = r1 - 1; s1 = s1 - 1; } r1 = r + 1; s1 = s + 1; while (r1 < pole.length && s1 < pole.length) { if (pole[r1][s1] == 1) { vysl++; } r1 = r1 + 1; s1 = s1 + 1; } r1 = r - 1; s1 = s + 1; while (r1 >= 0 && s1 < pole.length) { if (pole[r1][s1] == 1) { vysl++; } r1 = r1 - 1; s1 = s1 + 1; } r1 = r + 1; s1 = s - 1; while (r1 < pole.length && s1 >= 0) { if (pole[r1][s1] == 1) { vysl++; } r1 = r1 + 1; s1 = s1 - 1; } return vysl; } private static double ries(int[][] pole,int pocet) { double nas = 0; for (int i = 0; i < pole.length; i++) { for (int j = 0; j < pole[i].length; j++) { if (pole[i][j] == 1) { nas += nasiel(pole, i, j); } } } return ((double) nas) /(pocet*pocet) /*(pole.length * pole.length)*/; } }