There are N electrons present in the coordinate plane. For each electron, you have been given three values \(X_i, Y_i\) and \(K_i\), where \(X_i\) and \(Y_i\) denotes X coordinate and Y coordinates of electron in the plane and \(K_i\) denotes the self - potential energy of \(i^{th}\) electron if other electron weren't present in the plane. You have to calculate potential energy of this system of electrons which is given by following formula: \(\sum_{i=1}^{i=N} \sum_{j=1}^{j=N} K_i * K_j * DIST(i,j)\)
\(DIST(i,j)\) denotes floor of euclidean distance between \(i^{th}\) and \(j^{th}\) electron. That is, \(DIST(i,j) = \lfloor \sqrt {(X_{i}-X_{j})^{2} + (Y_{i}-Y_{j})^{2}} \rfloor\) where \( \lfloor \rfloor\) denotes floor function.
Since electrons are very small in size, there can be more than one electron present at a point.
INPUT:
First line will consists of integer N denoting total number of electrons. Next N lines will consists of three integers \(X_i, Y_i, K_i\).
OUTPUT:
Output potential energy of this system of electrons. Since output can be large print it modulo \(10^9+7\).
CONSTRAINTS:
\(1 \le N \le 10^6\)
\(1 \le X_i, Y_i, K_i \le 500\)
The potential energy of this system of electrons =
\((K_1 * K_1 * 0) + (K_1 * K_2 * 1) +\) \((K_1 * K_3 * 2) + (K_2 * K_1 * 1) +\) \((K_2 * K_2 * 0) + (K_2 * K_3 * 1) +\) \((K_3 * K_1 * 2) + (K_3 * K_2 * 1) +\) \((K_3 * K_3 * 0) = 32\).
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor