No.1649 Manhattan Square
Problem Statement
You are given $N$ points on a two-dimensional plane. The coordinates of the $i$-th point $p_i$ are $(x_i, y_i)$.
Find the sum of the squares of the Manhattan distances over all pairs of $2$ points, modulo $\bmod 998244353$. In other words, output the following value.
\[
\left( \sum_{i=1}^{N-1} \sum_{j=i+1}^{N} \left(|x_i - x_j| + |y_i - y_j|\right)^2 \right) \bmod 998244353
\]
Input
$N$ $x_1\ \ y_1$ $x_2\ \ y_2$ $\vdots$ $x_N\ \ y_N$
Output
Output the answer, followed by a newline.
Sample
Sample 1
Input
3
20 21
8 13
21 20
Output
804
- The Manhattan distance between $p_1$ and $p_2$ is $|20-8|+|21-13|=20$.
- The Manhattan distance between $p_1$ and $p_3$ is $|20-21|+|21-20|=2$.
- The Manhattan distance between $p_2$ and $p_3$ is $|8-21|+|13-20|=20$.
Sample 2
Input
10
820452084 718229520
553492242 206036568
836505501 213104158
629890367 87785981
743726641 227761681
179932548 523018260
617059779 887083076
857634650 10893928
540244583 891972563
122356429 76481779
Output
404638485
Find the answer modulo $\bmod 998244353$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
蜜蜂